ckuus5.c 390 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696
  1. #include "ckcsym.h"
  2. int xcmdsrc = 0;
  3. #ifdef NOICP
  4. int cmdsrc() { return(0); }
  5. #endif /* NOICP */
  6. /* C K U U S 5 -- "User Interface" for C-Kermit, part 5 */
  7. /*
  8. Authors:
  9. Frank da Cruz <fdc@columbia.edu>,
  10. The Kermit Project, New York City
  11. Jeffrey E Altman <jaltman@secure-endpoints.com>
  12. Secure Endpoints Inc., New York City
  13. Copyright (C) 1985, 2017,
  14. Trustees of Columbia University in the City of New York.
  15. All rights reserved. See the C-Kermit COPYING.TXT file or the
  16. copyright text in the ckcmai.c module for disclaimer and permissions.
  17. */
  18. /* Includes */
  19. #include "ckcdeb.h"
  20. #include "ckcasc.h"
  21. #include "ckcker.h"
  22. #include "ckuusr.h"
  23. #ifdef DCMDBUF
  24. char *line; /* Character buffer for anything */
  25. char *tmpbuf;
  26. #else
  27. char line[LINBUFSIZ+1];
  28. char tmpbuf[TMPBUFSIZ+1]; /* Temporary buffer */
  29. #endif /* DCMDBUF */
  30. char lasttakeline[TMPBUFSIZ+1]; /* Last TAKE-file line */
  31. #ifndef NOICP
  32. #include "ckcnet.h"
  33. #ifndef NOCSETS
  34. #include "ckcxla.h"
  35. #endif /* NOCSETS */
  36. #ifdef MAC
  37. #include "ckmasm.h"
  38. #endif /* MAC */
  39. #ifdef CK_SSL
  40. #include "ck_ssl.h"
  41. #endif /* CK_SSL */
  42. extern char * ck_cryear; /* (ckcmai.c) Latest C-Kermit copyright year */
  43. #ifdef OS2
  44. #include "ckoetc.h"
  45. #ifndef NT
  46. #define INCL_NOPM
  47. #define INCL_VIO /* Needed for ckocon.h */
  48. #include <os2.h>
  49. #undef COMMENT
  50. #else /* NT */
  51. #include <windows.h>
  52. #define TAPI_CURRENT_VERSION 0x00010004
  53. #include <tapi.h>
  54. #include <mcx.h>
  55. #include "ckntap.h"
  56. #define APIRET ULONG
  57. extern int DialerHandle;
  58. extern int StartedFromDialer;
  59. #endif /* NT */
  60. #include "ckocon.h"
  61. #include "ckokey.h"
  62. #ifdef KUI
  63. #include "ikui.h"
  64. #endif /* KUI */
  65. #ifdef putchar
  66. #undef putchar
  67. #endif /* putchar */
  68. #define putchar(x) conoc(x)
  69. extern int cursor_save ;
  70. extern bool cursorena[] ;
  71. #endif /* OS2 */
  72. /* 2010-03-09 SMS. VAX C V3.1-051 needs <stat.h> for off_t. */
  73. #ifdef VMS
  74. #include <stat.h>
  75. #endif /* def VMS */
  76. /* For formatted screens, "more?" prompting, etc. */
  77. #ifdef FT18
  78. #define isxdigit(c) isdigit(c)
  79. #endif /* FT18 */
  80. #ifdef STRATUS /* Stratus Computer, Inc. VOS */
  81. #ifdef putchar
  82. #undef putchar
  83. #endif /* putchar */
  84. #define putchar(x) conoc(x)
  85. #ifdef getchar
  86. #undef getchar
  87. #endif /* getchar */
  88. #define getchar(x) coninc(0)
  89. #endif /* STRATUS */
  90. /* External variables */
  91. extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
  92. binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  93. inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  94. zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  95. debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
  96. rcdactive, keepallchars, cmd_err;
  97. #ifdef LOCUS
  98. extern int locus, autolocus;
  99. #endif /* LOCUS */
  100. #ifndef NOMSEND
  101. extern int addlist;
  102. #endif /* NOMSEND */
  103. #ifdef CK_SPEED
  104. extern int prefixing;
  105. #endif /* CK_SPEED */
  106. extern int g_matchdot;
  107. #ifdef RECURSIVE
  108. extern int recursive;
  109. #endif /* RECURSIVE */
  110. extern int xfiletype;
  111. #ifdef IKSDCONF
  112. extern char * iksdconf;
  113. extern int iksdcf;
  114. #endif /* IKSDCONF */
  115. #ifdef CK_RECALL
  116. extern int on_recall;
  117. #endif /* CK_RECALL */
  118. extern int ngetpath, exitonclose;
  119. extern char * getpath[];
  120. extern CHAR * epktmsg;
  121. extern char * snd_move;
  122. extern char * snd_rename;
  123. extern char * rcv_move;
  124. extern char * rcv_rename;
  125. extern char * g_snd_move;
  126. extern char * g_snd_rename;
  127. extern char * g_rcv_move;
  128. extern char * g_rcv_rename;
  129. extern char * nm[];
  130. #ifdef CK_UTSNAME
  131. extern char unm_mch[];
  132. extern char unm_mod[];
  133. extern char unm_nam[];
  134. extern char unm_rel[];
  135. extern char unm_ver[];
  136. #endif /* CK_UTSNAME */
  137. #ifndef NOPUSH
  138. #ifndef NOFRILLS
  139. extern char editor[];
  140. extern char editfile[];
  141. extern char editopts[];
  142. #ifdef BROWSER
  143. extern char browser[];
  144. extern char browsopts[];
  145. extern char browsurl[];
  146. #endif /* BROWSER */
  147. #endif /* NOFRILLS */
  148. #endif /* NOPUSH */
  149. #ifndef NOFRILLS
  150. #ifndef NORENAME
  151. _PROTOTYP(VOID shorename, (void));
  152. #endif /* NORENAME */
  153. #endif /* NOFRILLS */
  154. #ifndef NOSERVER
  155. extern char * x_user, * x_passwd, * x_acct;
  156. #endif /* NOSERVER */
  157. #ifdef CKLOGDIAL
  158. extern int dialog;
  159. extern char diafil[];
  160. #endif /* CKLOGDIAL */
  161. #ifdef CKROOT
  162. extern int ckrooterr;
  163. #endif /* CKROOT */
  164. #ifndef NOSPL
  165. extern int cfilef, xxdot, vareval;
  166. extern char cmdfil[];
  167. struct localvar * localhead[CMDSTKL];
  168. struct localvar * localtail = NULL;
  169. struct localvar * localnext = NULL;
  170. _PROTOTYP( VOID shosexp, (void) );
  171. _PROTOTYP( static VOID shoinput, (void) );
  172. _PROTOTYP( static char gettok, (void) );
  173. _PROTOTYP( static VOID factor, (void) );
  174. _PROTOTYP( static VOID term, (void) );
  175. _PROTOTYP( static VOID termp, (void) );
  176. _PROTOTYP( static VOID exprp, (void) );
  177. _PROTOTYP( static VOID expr, (void) );
  178. _PROTOTYP( static VOID simple, (void) );
  179. _PROTOTYP( static VOID simpler, (void) );
  180. _PROTOTYP( static VOID simplest, (void) );
  181. _PROTOTYP( static CK_OFF_T xparse, (void) );
  182. #endif /* NOSPL */
  183. #ifndef NOSHOW
  184. _PROTOTYP( int sho_iks, (void) );
  185. #endif /* NOSHOW */
  186. #ifdef MAC
  187. char * ckprompt = "Mac-Kermit>"; /* Default prompt for Macintosh */
  188. char * ikprompt = "IKSD>";
  189. #else /* Not MAC */
  190. #ifdef NOSPL
  191. #ifdef OS2
  192. char * ckprompt = "K-95> "; /* Default prompt for Win32 */
  193. char * ikprompt = "IKSD> ";
  194. #else
  195. char * ckprompt = "C-Kermit>";
  196. char * ikprompt = "IKSD>";
  197. #endif /* NT */
  198. #else /* NOSPL */
  199. #ifdef OS2
  200. /* Default prompt for OS/2 and Win32 */
  201. /* fdc 2013-12-06 - C-Kermit 9.0 and later is just "C-Kermit" */
  202. #ifdef NT
  203. #ifdef COMMENT
  204. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
  205. #else
  206. char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] C-Kermit> ";
  207. #endif /* COMMENT */
  208. char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
  209. #else /* NT */
  210. #ifdef COMMENT
  211. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
  212. #else
  213. char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] C-Kermit> ";
  214. #endif /* COMMENT */
  215. char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
  216. #endif /* NT */
  217. #else /* OS2 */
  218. #ifdef VMS
  219. char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
  220. char * ikprompt = "\\v(dir) IKSD>";
  221. #else
  222. #ifdef UNIX
  223. /* Note: parens, not brackets, because of ISO646 */
  224. /* Collapse long paths using ~ notation if in home directory tree */
  225. char * ckprompt = "(\\freplace(\\v(dir),\\fpathname(\\v(home)),~/)) C-Kermit>";
  226. char * ikprompt = "(\\freplace(\\v(dir),\\fpathname(\\v(home)),~/)) IKSD>";
  227. #else
  228. /* Default prompt for other platforms */
  229. char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
  230. char * ikprompt = "(\\v(dir)) IKSD>";
  231. #endif /* UNIX */
  232. #endif /* VMS */
  233. #endif /* NT */
  234. #endif /* NOSPL */
  235. #endif /* MAC */
  236. #ifndef CCHMAXPATH
  237. #define CCHMAXPATH 257
  238. #endif /* CCHMAXPATH */
  239. char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */
  240. #ifdef TNCODE
  241. extern int tn_b_nlm; /* TELNET BINARY newline mode */
  242. #endif /* TNCODE */
  243. #ifndef NOKVERBS
  244. extern struct keytab kverbs[]; /* Table of \Kverbs */
  245. extern int nkverbs; /* Number of \Kverbs */
  246. #endif /* NOKVERBS */
  247. #ifndef NOPUSH
  248. extern int nopush;
  249. #endif /* NOPUSH */
  250. #ifdef CK_RECALL
  251. extern int cm_recall;
  252. #endif /* CK_RECALL */
  253. extern char *ccntab[];
  254. /* Printer stuff */
  255. extern char *printername;
  256. extern int printpipe;
  257. #ifdef BPRINT
  258. extern int printbidi, pportparity, pportflow;
  259. extern long pportspeed;
  260. #endif /* BPRINT */
  261. #ifdef OS2
  262. _PROTOTYP (int os2getcp, (void) );
  263. _PROTOTYP (int os2getcplist, (int *, int) );
  264. #ifdef OS2MOUSE
  265. extern int tt_mouse;
  266. #endif /* OS2MOUSE */
  267. extern int tt_update, tt_updmode, updmode, tt_utf8;
  268. #ifndef IKSDONLY
  269. extern int tt_status[];
  270. #endif /* IKSDONLY */
  271. #ifdef PCFONTS
  272. extern struct keytab term_font[];
  273. #else
  274. #ifdef KUI
  275. extern struct keytab * term_font;
  276. #endif /* KUI */
  277. #endif /* PCFONTS */
  278. extern int ntermfont, tt_font, tt_font_size;
  279. extern unsigned char colornormal, colorunderline, colorstatus,
  280. colorhelp, colorselect, colorborder, colorgraphic, colordebug,
  281. colorreverse, colorcmd, coloritalic;
  282. extern int priority;
  283. extern struct keytab prtytab[];
  284. extern int nprty;
  285. char * cmdmac = NULL;
  286. #endif /* OS2 */
  287. #ifdef VMS
  288. _PROTOTYP (int zkermini, (char *, int, char *) );
  289. #endif /* VMS */
  290. extern long vernum;
  291. extern int inecho, insilence, inbufsize, nvars, inintr;
  292. extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
  293. *cknetv, *clcmds;
  294. #ifdef OS2
  295. extern char *ckyv;
  296. #endif /* OS2 */
  297. #ifdef CK_AUTHENTICATION
  298. extern char * ckathv;
  299. #endif /* CK_AUTHENTICATION */
  300. #ifdef CK_SSL
  301. extern char * cksslv;
  302. #endif /* CK_SSL */
  303. #ifdef CK_ENCRYPTION
  304. #ifndef CRYPT_DLL
  305. extern char * ckcrpv;
  306. #endif /* CRYPT_DLL */
  307. #endif /* CK_ENCRYPTION */
  308. #ifdef SSHBUILTIN
  309. extern char *cksshv;
  310. #ifdef SFTP_BUILTIN
  311. extern char *cksftpv;
  312. #endif /* SFTP_BUILTIN */
  313. #endif /* SSHBUILTIN */
  314. #ifdef TNCODE
  315. extern char *cktelv;
  316. #endif /* TNCODE */
  317. #ifndef NOFTP
  318. #ifndef SYSFTP
  319. extern char * ckftpv;
  320. #endif /* SYSFTP */
  321. #endif /* NOFTP */
  322. extern int srvidl;
  323. #ifdef OS2
  324. extern char *ckonetv;
  325. extern int interm;
  326. #ifdef CK_NETBIOS
  327. extern char *ckonbiv;
  328. #endif /* CK_NETBIOS */
  329. #ifdef OS2MOUSE
  330. extern char *ckomouv;
  331. #endif /* OS2MOUSE */
  332. #endif /* OS2 */
  333. #ifndef NOLOCAL
  334. extern char *connv;
  335. #endif /* NOLOCAL */
  336. #ifndef NODIAL
  337. extern char *dialv;
  338. #endif /* NODIAL */
  339. #ifndef NOSCRIPT
  340. extern char *loginv;
  341. extern int secho;
  342. #endif /* NOSCRIPT */
  343. #ifndef NODIAL
  344. extern int nmdm, dirline;
  345. extern struct keytab mdmtab[];
  346. #endif /* NODIAL */
  347. extern int network, nettype, ttnproto;
  348. #ifdef OS2
  349. #ifndef NOTERM
  350. /* SET TERMINAL items... */
  351. extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
  352. extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
  353. extern char answerback[];
  354. extern struct tt_info_rec tt_info[]; /* Indexed by terminal type */
  355. extern int max_tt;
  356. #endif /* NOTERM */
  357. #endif /* OS2 */
  358. _PROTOTYP( VOID shotrm, (void) );
  359. _PROTOTYP( int shofea, (void) );
  360. #ifdef OS2
  361. extern int tt_rows[], tt_cols[];
  362. #else /* OS2 */
  363. extern int tt_rows, tt_cols;
  364. #endif /* OS2 */
  365. extern int cmd_rows, cmd_cols;
  366. #ifdef CK_TMPDIR
  367. extern int f_tmpdir; /* Directory changed temporarily */
  368. extern char savdir[]; /* Temporary directory */
  369. #endif /* CK_TMPDIR */
  370. #ifndef NOLOCAL
  371. extern int tt_crd, tt_lfd, tt_escape;
  372. #endif /* NOLOCAL */
  373. #ifndef NOCSETS
  374. extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
  375. extern struct keytab fcstab[];
  376. extern struct csinfo fcsinfo[];
  377. #ifndef MAC
  378. extern struct keytab ttcstab[];
  379. #endif /* MAC */
  380. #endif /* NOCSETS */
  381. extern long speed;
  382. #ifndef NOXMIT
  383. extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
  384. extern char xmitbuf[];
  385. #endif /* NOXMIT */
  386. extern char **xargv, *versio, *ckxsys, *dftty, *lp;
  387. #ifdef DCMDBUF
  388. extern char *cmdbuf, *atmbuf; /* Command buffers */
  389. #ifndef NOSPL
  390. extern char *savbuf; /* Command buffers */
  391. #endif /* NOSPL */
  392. #else
  393. extern char cmdbuf[], atmbuf[]; /* Command buffers */
  394. #ifndef NOSPL
  395. extern char savbuf[]; /* Command buffers */
  396. #endif /* NOSPL */
  397. #endif /* DCMDBUF */
  398. extern char toktab[], ttname[], psave[];
  399. extern CHAR sstate, feol;
  400. extern int cmflgs, techo, repars, ncmd;
  401. extern struct keytab cmdtab[];
  402. #ifndef NOSETKEY
  403. KEY *keymap;
  404. #ifndef OS2
  405. #define mapkey(x) keymap[x]
  406. #endif /* OS2 */
  407. MACRO *macrotab;
  408. _PROTOTYP( VOID shostrdef, (CHAR *) );
  409. #endif /* NOSETKEY */
  410. extern int cmdlvl;
  411. #ifndef NOSPL
  412. extern struct mtab *mactab;
  413. extern struct keytab mackey[];
  414. extern struct keytab vartab[], fnctab[], iftab[];
  415. extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
  416. #endif /* NOSPL */
  417. FILE *tfile[MAXTAKE]; /* TAKE file stack */
  418. char *tfnam[MAXTAKE]; /* Name of TAKE file */
  419. int tfline[MAXTAKE]; /* Current line number */
  420. int tfblockstart[MAXTAKE]; /* Current block-start line */
  421. int topcmd = -1; /* cmdtab index of current command */
  422. int havetoken = 0;
  423. extern int dblquo; /* Doublequoting enabled */
  424. #ifdef DCMDBUF /* Initialization filespec */
  425. char *kermrc = NULL;
  426. #else
  427. char kermrcb[KERMRCL];
  428. char *kermrc = kermrcb;
  429. #endif /* DCMDBUF */
  430. int noherald = 0;
  431. int cm_retry = 1; /* Command retry enabled */
  432. xx_strp xxstring = zzstring;
  433. #ifndef NOXFER
  434. extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  435. keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  436. srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  437. fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;
  438. #ifdef CK_AUTODL
  439. extern int inautodl, cmdadl;
  440. #endif /* CK_AUTODL */
  441. #ifndef NOSERVER
  442. extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  443. en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  444. en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
  445. #endif /* NOSERVER */
  446. extern int atcapr,
  447. atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  448. attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
  449. #ifdef STRATUS
  450. extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
  451. #endif /* STRATUS */
  452. #ifdef CK_PERMS
  453. extern int atlpri, atlpro, atgpri, atgpro;
  454. #endif /* CK_PERMS */
  455. #ifdef CK_LOGIN
  456. extern char * anonfile; /* Anonymous login init file */
  457. extern char * anonroot; /* Anonymous file-system root */
  458. extern char * userfile; /* Forbidden user file */
  459. extern int isguest; /* Flag for anonymous user */
  460. #endif /* CK_LOGIN */
  461. #endif /* NOXFER */
  462. #ifdef DCMDBUF
  463. int *xquiet = NULL;
  464. int *xvarev = NULL;
  465. #else
  466. int xquiet[CMDSTKL];
  467. int xvarev[CMDSTKL];
  468. #endif /* DCMDBUF */
  469. char * prstring[CMDSTKL];
  470. #ifndef NOSPL
  471. extern long ck_alarm;
  472. extern char alrm_date[], alrm_time[];
  473. /* Local declarations */
  474. static int nulcmd = 0; /* Flag for next cmd to be ignored */
  475. /* Definitions for predefined macros */
  476. /* First, the single-line macros, installed with addmac()... */
  477. /* IBM-LINEMODE macro */
  478. char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";
  479. /* FATAL macro */
  480. char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";
  481. #ifdef CK_SPEED
  482. #ifdef IRIX65
  483. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  484. #else
  485. #ifdef IRIX
  486. /* Because of bug in telnet server */
  487. char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
  488. set pref cautious";
  489. #else
  490. #ifdef pdp11
  491. char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
  492. #else
  493. #ifdef BIGBUFOK
  494. char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
  495. #else
  496. char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
  497. #endif /* BIGBUFOK */
  498. #endif /* IRIX */
  499. #endif /* IRIX65 */
  500. #endif /* pdp11 */
  501. #ifdef pdp11
  502. char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
  503. #else
  504. char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
  505. #endif /* pdp11 */
  506. char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
  507. set reliable off, set clearchannel off, set send timeout 20 fixed";
  508. #else
  509. #ifdef BIGBUFOK
  510. #ifdef IRIX65
  511. char *m_fast = "set win 30, set rec pack 4000";
  512. #else
  513. #ifdef IRIX
  514. char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
  515. #else
  516. char *m_fast = "set win 30, set rec pack 4000";
  517. #endif /* IRIX */
  518. #endif /* IRIX65 */
  519. #else /* Not BIGBUFOK */
  520. char *m_fast = "set win 4, set rec pack 2200";
  521. #endif /* BIGBUFOK */
  522. char *m_cautious = "set win 4, set rec pack 1000";
  523. char *m_robust = "set win 1, set rec pack 90, set reliable off,\
  524. set send timeout 20 fixed";
  525. #endif /* CK_SPEED */
  526. #ifdef VMS
  527. char *m_purge = "run purge \\%*";
  528. #endif /* VMS */
  529. #ifdef OS2
  530. char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
  531. #endif /* OS2 */
  532. /* Now the multiline macros, defined with addmmac()... */
  533. /*
  534. Kermit's scripting language is so much more powerful than C that it was
  535. about a thousand time easier to implement FOR, WHILE, IF, and SWITCH
  536. commands as internal Kermit macros. This was done in 1996 for C-Kermit 6.0.
  537. The following definitions, down to #ifdef COMMENT, are from C-Kermit
  538. 9.0.304 Dev.22, April 2017, where the command parser was changed to not
  539. evaluate macro arguments on the DO command line, but to defer evaluation
  540. until after the arguments had been separated and counted. This change
  541. required subtle modifications to the internal macro templates.
  542. IMPORTANT: Internal macros must have names that start with '_', followed
  543. by three letters, e.g. _whi for WHILE. The definitions below are just
  544. templates for some other code that constructs the actual menu to be
  545. executed by filling in the \%x variables. The generated macros have names
  546. like _whil2, _whil3, etc, where the trailing number is the execution stack
  547. level. The reason for the strict naming convention is so internal macros
  548. can be parsed differently than regular ones. See
  549. ckuusr.c:isinternalmacro(), which determines the type of macro.
  550. */
  551. /*
  552. The WHILE macro:
  553. \%1 = Loop condition
  554. \%2 = Loop body
  555. */
  556. char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
  557. ":_..inc,\\fcontents(\\%1),\\fcontents(\\%2),goto _..inc,:_..bot,_putargs},",
  558. "_define break goto _..bot, _define continue goto _..inc,",
  559. "do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
  560. ""};
  561. /*
  562. FOR macro for \%i-style loop variables (see dofor()...)
  563. \%1 = Loop variable
  564. \%2 = Initial value (can be an expression)
  565. \%3 = Loop exit value
  566. \%4 = Loop increment
  567. \%5 = > or <
  568. \%6 = Loop body
  569. */
  570. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  571. "define \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  572. "\\fcontents(\\%6),:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  573. "define break goto _..bot, define continue goto _..inc,",
  574. "do _for\\v(cmdlevel) \\\\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  575. ""};
  576. /*
  577. FOR macro when the loop variable is itself a macro, with same arguments
  578. but slightly different quoting.
  579. */
  580. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  581. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  582. "\\fcontents(\\%6),:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  583. "def break goto _..bot, def continue goto _..inc,",
  584. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  585. ""};
  586. /*
  587. SWITCH macro
  588. \%1 = Switch variable
  589. \%2 = Switch body
  590. */
  591. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  592. "_forward {\\fcontents(\\%1)},\\fcontents(\\%2),:default,:_..bot,_putargs},_def break goto _..bot,",
  593. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  594. ""};
  595. /*
  596. IF macro
  597. /%1 = Commands to execute (IF part and ELSE part if any)
  598. */
  599. char *xif_def[] = {
  600. "_assign _if_\\v(cmdlevel) {_getargs,\\fcontents(\\%1),_putargs},",
  601. "do _if_\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  602. ""};
  603. #ifdef COMMENT
  604. /* Internal macro definitions for C-Kermit 6.0 through 9.0.302 */
  605. char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  606. "def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
  607. "\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
  608. "def break goto _..bot, def continue goto _..inc,",
  609. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  610. ""};
  611. char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
  612. "def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
  613. "\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
  614. "def break goto _..bot, def continue goto _..inc,",
  615. "do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
  616. ""};
  617. /* SWITCH macro */
  618. char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
  619. "_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
  620. "do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
  621. ""};
  622. /* XIF macro */
  623. char *xif_def[] = {
  624. "_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
  625. "do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
  626. ""};
  627. #endif /* COMMENT */
  628. /*
  629. Variables declared here for use by other ckuus*.c modules.
  630. Space is allocated here to save room in ckuusr.c.
  631. */
  632. #ifdef DCMDBUF
  633. struct cmdptr *cmdstk;
  634. int
  635. *ifcmd = NULL,
  636. *count = NULL,
  637. *iftest = NULL,
  638. *intime = NULL,
  639. *inpcas = NULL,
  640. *takerr = NULL,
  641. *merror = NULL;
  642. #else
  643. struct cmdptr cmdstk[CMDSTKL];
  644. int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  645. inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
  646. #endif /* DCMDBUF */
  647. /* Macro stack */
  648. #ifdef COMMENT
  649. char *topline = NULL; /* Program invocation arg line */
  650. char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
  651. #endif /* COMMENT */
  652. char **m_xarg[MACLEVEL]; /* Pointers to arg vector arrays */
  653. int n_xarg[MACLEVEL]; /* Sizes of arg vector arrays */
  654. char *m_arg[MACLEVEL][NARGS]; /* Args of each level */
  655. int macargc[MACLEVEL]; /* Argc of each level */
  656. char *macp[MACLEVEL]; /* Current position in each macro */
  657. char *macx[MACLEVEL]; /* Beginning of each macro def */
  658. char *mrval[MACLEVEL]; /* RETURN value at each level */
  659. int lastcmd[MACLEVEL]; /* Last command at each level */
  660. int topargc = 0; /* Argc at top level */
  661. char **topxarg = NULL; /* Argv at top level */
  662. char *toparg[MAXARGLIST+2];
  663. /* Global Variables */
  664. char *g_var[GVARS+1]; /* Global \%a..z pointers */
  665. extern char varnam[]; /* \%x variable name buffer */
  666. /* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
  667. /* Note: a_link[x] < 0 means no link; >= 0 is a link */
  668. char **a_ptr[32]; /* Array pointers, for arrays a-z */
  669. int a_dim[32]; /* Dimensions for each array */
  670. int a_link[32]; /* Link (index of linked-to-array) */
  671. char **aa_ptr[CMDSTKL][32]; /* Array stack for automatic arrays */
  672. int aa_dim[CMDSTKL][32]; /* Dimensions for each array */
  673. /* INPUT command buffers and variables */
  674. char * inpbuf = NULL; /* Buffer for INPUT and REINPUT */
  675. extern char * inpbp; /* Global/static pointer to it */
  676. char inchar[2] = { NUL, NUL }; /* Last character that was INPUT */
  677. int incount = 0; /* INPUT character count */
  678. extern int instatus; /* INPUT status */
  679. static char * i_text[] = { /* INPUT status text */
  680. "success", "timeout", "interrupted", "internal error", "i/o error"
  681. };
  682. char lblbuf[LBLSIZ]; /* Buffer for labels */
  683. #else /* NOSPL */
  684. int takerr[MAXTAKE];
  685. #endif /* NOSPL */
  686. static char *prevdir = NULL;
  687. int pacing = 0; /* OUTPUT pacing */
  688. char *tp; /* Temporary buffer pointer */
  689. int timelimit = 0, asktimer = 0; /* Timers for time-limited commands */
  690. #ifdef CK_APC /* Application Program Command (APC) */
  691. int apcactive = APC_INACTIVE;
  692. int apcstatus = APC_OFF; /* OFF by default everywhere */
  693. #ifdef DCMDBUF
  694. char *apcbuf;
  695. #else
  696. char apcbuf[APCBUFLEN];
  697. #endif /* DCMDBUF */
  698. #endif /* CK_APC */
  699. extern char pktfil[],
  700. #ifdef DEBUG
  701. debfil[],
  702. #endif /* DEBUG */
  703. #ifdef TLOG
  704. trafil[],
  705. #endif /* TLOG */
  706. sesfil[];
  707. #ifndef NOFRILLS
  708. extern int rmailf, rprintf; /* REMOTE MAIL & PRINT items */
  709. extern char optbuf[];
  710. #endif /* NOFRILLS */
  711. extern int noinit; /* Flat to skip init file */
  712. #ifndef NOSPL
  713. static struct keytab kcdtab[] = { /* Symbolic directory names */
  714. #ifdef NT
  715. { "appdata", VN_APPDATA, 0 },
  716. { "common", VN_COMMON, 0 },
  717. { "desktop", VN_DESKTOP, 0 },
  718. #endif /* NT */
  719. { "download", VN_DLDIR, 0 },
  720. #ifdef OS2ORUNIX
  721. { "exedir", VN_EXEDIR, 0 },
  722. #endif /* OS2ORUNIX */
  723. { "home", VN_HOME, 0 },
  724. { "inidir", VN_INI, 0 },
  725. #ifdef UNIX
  726. { "lockdir", VN_LCKDIR, 0 },
  727. #endif /* UNIX */
  728. #ifdef NT
  729. { "my_documents",VN_PERSONAL, 0 },
  730. { "personal", VN_PERSONAL, CM_INV },
  731. #endif /* NT */
  732. { "startup", VN_STAR, 0 },
  733. { "textdir", VN_TXTDIR, 0 },
  734. { "tmpdir", VN_TEMP, 0 }
  735. };
  736. static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
  737. #endif /* NOSPL */
  738. #ifndef NOSPL
  739. _PROTOTYP( VOID freelocal, (int) );
  740. _PROTOTYP( static CK_OFF_T expon, (CK_OFF_T, CK_OFF_T) );
  741. _PROTOTYP( static CK_OFF_T gcd, (CK_OFF_T, CK_OFF_T) );
  742. _PROTOTYP( static CK_OFF_T fact, (CK_OFF_T) );
  743. int /* Initialize macro data structures. */
  744. macini() { /* Allocate mactab and preset the first element. */
  745. int i;
  746. if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
  747. return(-1);
  748. mactab[0].kwd = NULL;
  749. mactab[0].mval = NULL;
  750. mactab[0].flgs = 0;
  751. for (i = 0; i < MACLEVEL; i++)
  752. localhead[i] = NULL;
  753. return(0);
  754. }
  755. #endif /* NOSPL */
  756. /* C M D S R C -- Returns current command source */
  757. /* 0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */
  758. /*
  759. As of 19 Aug 2000 this routine is obsolete. The scalar global variable
  760. xcmdsrc can be checked instead to save the overhead of a function call.
  761. */
  762. int
  763. cmdsrc() {
  764. #ifdef COMMENT
  765. return(xcmdsrc);
  766. #else
  767. #ifndef NOSPL
  768. if (cmdlvl == 0)
  769. return(0);
  770. else if (cmdstk[cmdlvl].src == CMD_MD)
  771. return(2);
  772. else if (cmdstk[cmdlvl].src == CMD_TF)
  773. return(1);
  774. else
  775. return(-1);
  776. #else
  777. if (tlevel < 0)
  778. return(0);
  779. else
  780. return(1);
  781. #endif /* NOSPL */
  782. #endif /* COMMENT */
  783. }
  784. /* C M D I N I -- Initialize the interactive command parser */
  785. static int cmdinited = 0; /* Command parser initialized */
  786. extern int cmdint; /* Interrupts are allowed */
  787. #ifdef CK_AUTODL
  788. int cmdadl = 1; /* Autodownload */
  789. #else
  790. int cmdadl = 0;
  791. #endif /* CK_AUTODL */
  792. char * k_info_dir = NULL; /* Where to find text files */
  793. #ifdef UNIX
  794. static char * txtdir[] = {
  795. "/usr/local/doc/", /* Linux, SunOS, ... */
  796. "/usr/share/lib/", /* HP-UX 10.xx... */
  797. "/usr/share/doc/", /* Other possibilities... */
  798. "/usr/local/lib/", /* NOTE: Each of these is tried */
  799. "/usr/local/share/", /* as is, and also with a kermit */
  800. "/usr/local/share/doc/", /* subdirectory. */
  801. "/usr/local/share/lib/",
  802. "/opt/kermit/", /* Solaris */
  803. "/opt/kermit/doc/",
  804. "/opt/",
  805. "/usr/doc/",
  806. "/doc/",
  807. ""
  808. };
  809. #endif /* UNIX */
  810. /*
  811. lookup() cache to speed up script execution.
  812. This is a static cache. Items are stored in decreasing frequency of
  813. reference based on statistics from a range of scripts. This gives
  814. better performance than a dynamic cache, which would require a lot more
  815. code and also would require system-dependent elements including system
  816. calls (e.g. to get subsecond times for entry aging).
  817. */
  818. #ifdef USE_LUCACHE /* Set in ckuusr.h */
  819. #define LUCACHE 32 /* Change this to reduce cache size */
  820. int lusize = 0;
  821. char * lucmd[LUCACHE];
  822. int luval[LUCACHE];
  823. int luidx[LUCACHE];
  824. struct keytab * lutab[LUCACHE];
  825. #endif /* USE_LUCACHE */
  826. static VOID
  827. luinit() { /* Initialize lookup() cache */
  828. int x, y;
  829. #ifdef USE_LUCACHE
  830. x = lookup(cmdtab,"if",ncmd,&y);
  831. lucmd[lusize] = "if";
  832. luval[lusize] = x;
  833. luidx[lusize] = y;
  834. lutab[lusize] = cmdtab;
  835. if (++lusize > LUCACHE) return;
  836. x = lookup(iftab,"not",nif,&y);
  837. lucmd[lusize] = "not";
  838. luval[lusize] = x;
  839. luidx[lusize] = y;
  840. lutab[lusize] = iftab;
  841. if (++lusize > LUCACHE) return;
  842. x = lookup(vartab,"cmdlevel",nvars,&y);
  843. lucmd[lusize] = "cmdlevel";
  844. luval[lusize] = x;
  845. luidx[lusize] = y;
  846. lutab[lusize] = vartab;
  847. if (++lusize > LUCACHE) return;
  848. x = lookup(cmdtab,"goto",ncmd,&y);
  849. lucmd[lusize] = "goto";
  850. luval[lusize] = x;
  851. luidx[lusize] = y;
  852. lutab[lusize] = cmdtab;
  853. if (++lusize > LUCACHE) return;
  854. x = lookup(iftab,">",nif,&y);
  855. lucmd[lusize] = ">";
  856. luval[lusize] = x;
  857. luidx[lusize] = y;
  858. lutab[lusize] = iftab;
  859. if (++lusize > LUCACHE) return;
  860. x = lookup(cmdtab,"incr",ncmd,&y);
  861. lucmd[lusize] = "incr";
  862. luval[lusize] = x;
  863. luidx[lusize] = y;
  864. lutab[lusize] = cmdtab;
  865. if (++lusize > LUCACHE) return;
  866. x = lookup(cmdtab,"def",ncmd,&y);
  867. lucmd[lusize] = "def";
  868. luval[lusize] = x;
  869. luidx[lusize] = y;
  870. lutab[lusize] = cmdtab;
  871. if (++lusize > LUCACHE) return;
  872. x = lookup(cmdtab,"_assign",ncmd,&y);
  873. lucmd[lusize] = "_assign";
  874. luval[lusize] = x;
  875. luidx[lusize] = y;
  876. lutab[lusize] = cmdtab;
  877. if (++lusize > LUCACHE) return;
  878. x = lookup(cmdtab,"echo",ncmd,&y);
  879. lucmd[lusize] = "echo";
  880. luval[lusize] = x;
  881. luidx[lusize] = y;
  882. lutab[lusize] = cmdtab;
  883. if (++lusize > LUCACHE) return;
  884. x = lookup(fnctab,"eval",nfuncs,&y);
  885. lucmd[lusize] = "eval";
  886. luval[lusize] = x;
  887. luidx[lusize] = y;
  888. lutab[lusize] = fnctab;
  889. if (++lusize > LUCACHE) return;
  890. x = lookup(fnctab,"lit",nfuncs,&y);
  891. lucmd[lusize] = "lit";
  892. luval[lusize] = x;
  893. luidx[lusize] = y;
  894. lutab[lusize] = fnctab;
  895. if (++lusize > LUCACHE) return;
  896. x = lookup(cmdtab,"do",ncmd,&y);
  897. lucmd[lusize] = "do";
  898. luval[lusize] = x;
  899. luidx[lusize] = y;
  900. lutab[lusize] = cmdtab;
  901. if (++lusize > LUCACHE) return;
  902. x = lookup(cmdtab,"_getargs",ncmd,&y);
  903. lucmd[lusize] = "_getargs";
  904. luval[lusize] = x;
  905. luidx[lusize] = y;
  906. lutab[lusize] = cmdtab;
  907. if (++lusize > LUCACHE) return;
  908. x = lookup(iftab,"<",nif,&y);
  909. lucmd[lusize] = "<";
  910. luval[lusize] = x;
  911. luidx[lusize] = y;
  912. lutab[lusize] = iftab;
  913. if (++lusize > LUCACHE) return;
  914. x = lookup(cmdtab,"_putargs",ncmd,&y);
  915. lucmd[lusize] = "_putargs";
  916. luval[lusize] = x;
  917. luidx[lusize] = y;
  918. lutab[lusize] = cmdtab;
  919. if (++lusize > LUCACHE) return;
  920. x = lookup(cmdtab,"asg",ncmd,&y);
  921. lucmd[lusize] = "asg";
  922. luval[lusize] = x;
  923. luidx[lusize] = y;
  924. lutab[lusize] = cmdtab;
  925. if (++lusize > LUCACHE) return;
  926. x = lookup(cmdtab,"else",ncmd,&y);
  927. lucmd[lusize] = "else";
  928. luval[lusize] = x;
  929. luidx[lusize] = y;
  930. lutab[lusize] = cmdtab;
  931. #endif /* USE_LUCACHE */
  932. }
  933. VOID
  934. cmdini() {
  935. int i = 0, x = 0, y = 0, z = 0, skip = 0;
  936. char * p;
  937. #ifdef TTSPDLIST
  938. long * ss = NULL;
  939. extern int nspd;
  940. extern struct keytab * spdtab;
  941. #endif /* TTSPDLIST */
  942. #ifndef NOSPL
  943. /*
  944. On stack to allow recursion!
  945. */
  946. char vnambuf[VNAML]; /* Buffer for variable names */
  947. #endif /* NOSPL */
  948. if (cmdinited) /* Already initialized */
  949. return; /* Don't do it again */
  950. for (i = 0; i < CMDSTKL; i++) /* Prompt strings for each */
  951. prstring[i] = NULL; /* command level */
  952. #ifndef NOCSETS
  953. p = getenv("K_CHARSET"); /* Set default file character set */
  954. if (p) { /* from environment */
  955. x = lookup(fcstab,p,nfilc,&y);
  956. if (x > -1)
  957. fcharset = x;
  958. }
  959. #endif /* NOCSETS */
  960. p = getenv("K_INFO_DIRECTORY"); /* Find Kermit info directory */
  961. if (p && *p && strlen(p) <= CKMAXPATH)
  962. makestr(&k_info_dir,p);
  963. if (!k_info_dir) {
  964. p = getenv("K_INFO_DIR");
  965. if (p && *p && strlen(p) <= CKMAXPATH)
  966. makestr(&k_info_dir,p);
  967. }
  968. #ifdef UNIX
  969. if (k_info_dir) { /* Look for Kermit docs directory */
  970. if (zchki(k_info_dir) == -2) {
  971. char xbuf[CKMAXPATH+32], *s = "";
  972. if (ckrchar(k_info_dir) != '/')
  973. s = "/";
  974. ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
  975. if (zchki(xbuf) < 0)
  976. makestr(&k_info_dir,NULL);
  977. }
  978. }
  979. if (!k_info_dir) {
  980. char xbuf[CKMAXPATH+32];
  981. int i;
  982. for (i = 0; *(txtdir[i]); i++) {
  983. ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
  984. if (zchki(xbuf) > 0) {
  985. makestr(&k_info_dir,txtdir[i]);
  986. debug(F110,"k_info_dir 1",k_info_dir,0);
  987. break;
  988. }
  989. ckmakmsg(xbuf,CKMAXPATH+32,
  990. txtdir[i],"kermit/","ckubwr.txt",NULL);
  991. if (zchki(xbuf) > 0) {
  992. ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
  993. makestr(&k_info_dir,xbuf);
  994. debug(F110,"k_info_dir 2",k_info_dir,0);
  995. break;
  996. }
  997. ckmakmsg(xbuf,CKMAXPATH+32,
  998. txtdir[i],"ckermit/","ckubwr.txt",NULL);
  999. if (zchki(xbuf) > 0) {
  1000. ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
  1001. makestr(&k_info_dir,xbuf);
  1002. debug(F110,"k_info_dir 3",k_info_dir,0);
  1003. break;
  1004. }
  1005. }
  1006. if (k_info_dir) { /* Make sure it ends with "/" */
  1007. if (ckrchar(k_info_dir) != '/') {
  1008. char xbuf[CKMAXPATH+32];
  1009. ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
  1010. makestr(&k_info_dir,xbuf);
  1011. }
  1012. }
  1013. }
  1014. #else
  1015. #ifdef OS2
  1016. {
  1017. char xdir[CKMAXPATH+8], *s = "";
  1018. extern char startupdir[];
  1019. xdir[0] = NUL;
  1020. if (ckrchar(startupdir) != '/')
  1021. s = "/";
  1022. if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
  1023. ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
  1024. makestr(&k_info_dir,xdir);
  1025. }
  1026. #endif /* OS2 */
  1027. #endif /* UNIX */
  1028. #ifdef TTSPDLIST
  1029. if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
  1030. int j, k, m = 0, n; /* Create sorted keyword table */
  1031. char buf[16];
  1032. char * p;
  1033. if ((spdtab =
  1034. (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
  1035. for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
  1036. if (ss[i] < 1L) break; /* Shouldn't happen */
  1037. buf[0] = NUL; /* Make string */
  1038. sprintf(buf,"%ld",ss[i]); /* SAFE */
  1039. if (ss[i] == 8880L)
  1040. ckstrncpy(buf,"75/1200",sizeof(buf));
  1041. if (ss[i] == 134L)
  1042. ckstrncat(buf,".5",16);
  1043. n = strlen(buf);
  1044. if ((n > 0) && (p = (char *)malloc(n+1))) {
  1045. if (m > 0) { /* Have at least one in list */
  1046. for (j = 0; /* Find slot */
  1047. j < m && strcmp(buf,spdtab[j].kwd) > 0;
  1048. j++
  1049. )
  1050. ;
  1051. if (j < m) { /* Must insert */
  1052. for (k = m-1; k >= j; k--) { /* Move others down */
  1053. spdtab[k+1].kwd = spdtab[k].kwd;
  1054. spdtab[k+1].flgs = spdtab[k].flgs;
  1055. spdtab[k+1].kwval = spdtab[k].kwval;
  1056. }
  1057. }
  1058. } else /* First one */
  1059. j = 0;
  1060. ckstrncpy(p,buf,n+1); /* Add new speed */
  1061. spdtab[j].kwd = p;
  1062. spdtab[j].flgs = 0;
  1063. spdtab[j].kwval = (int) ss[i] / 10;
  1064. m++; /* Count this one */
  1065. }
  1066. }
  1067. }
  1068. nspd = m;
  1069. }
  1070. #endif /* TTSPDLIST */
  1071. #ifndef NOSPL
  1072. /* Allocate INPUT command buffer */
  1073. if (!inpbuf) {
  1074. if (!(inpbuf = (char *) malloc(INPBUFSIZ+8)))
  1075. fatal("cmdini: no memory for INPUT buffer");
  1076. }
  1077. for (x = 0; x < INPBUFSIZ; x++) /* Initialize it */
  1078. inpbuf[x] = NUL;
  1079. inpbp = inpbuf; /* Initialize pointer */
  1080. inbufsize = INPBUFSIZ; /* and size. */
  1081. #endif /* NOSPL */
  1082. #ifdef DCMDBUF
  1083. if (cmsetup() < 0) fatal("Can't allocate command buffers!");
  1084. #ifndef NOSPL
  1085. /* Allocate command stack allowing command parser to call itself */
  1086. if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
  1087. fatal("cmdini: no memory for cmdstk");
  1088. if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
  1089. fatal("cmdini: no memory for ifcmd");
  1090. if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
  1091. fatal("cmdini: no memory for count");
  1092. if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
  1093. fatal("cmdini: no memory for iftest");
  1094. if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
  1095. fatal("cmdini: no memory for intime");
  1096. if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
  1097. fatal("cmdini: no memory for inpcas");
  1098. if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
  1099. fatal("cmdini: no memory for takerr");
  1100. if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
  1101. fatal("cmdini: no memory for merror");
  1102. if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
  1103. fatal("cmdini: no memory for xquiet");
  1104. if (!(xvarev = (int *) malloc(sizeof(int)*CMDSTKL)))
  1105. fatal("cmdini: no memory for xvarev");
  1106. if (!kermrc)
  1107. if (!(kermrc = (char *) malloc(KERMRCL+1)))
  1108. fatal("cmdini: no memory for kermrc");
  1109. #ifdef CK_APC
  1110. /* Application Program Command buffer */
  1111. if (!(apcbuf = malloc(APCBUFLEN + 1)))
  1112. fatal("cmdini: no memory for apcbuf");
  1113. #endif /* CK_APC */
  1114. #endif /* NOSPL */
  1115. /* line[] and tmpbuf[] are the two string buffers used by the command parser */
  1116. if (!(line = malloc(LINBUFSIZ + 1)))
  1117. fatal("cmdini: no memory for line");
  1118. if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
  1119. fatal("cmdini: no memory for tmpbuf");
  1120. #endif /* DCMDBUF */
  1121. #ifndef NOSPL
  1122. #ifdef CK_MINPUT
  1123. { /* Initialize MINPUT pointers */
  1124. int i;
  1125. extern char *ms[];
  1126. for (i = 0; i < MINPMAX; i++)
  1127. ms[i] = NULL;
  1128. }
  1129. #endif /* CK_MINPUT */
  1130. if (macini() < 0) /* Allocate macro buffers */
  1131. fatal("Can't allocate macro buffers!");
  1132. ifcmd[0] = 0; /* Command-level related variables. */
  1133. iftest[0] = 0; /* Initialize variables at top level */
  1134. count[0] = 0; /* of stack... */
  1135. intime[0] = 0;
  1136. inpcas[0] = 0;
  1137. takerr[0] = 0;
  1138. merror[0] = 0;
  1139. xquiet[0] = quiet;
  1140. xvarev[0] = vareval;
  1141. #endif /* NOSPL */
  1142. #ifndef NOSPL
  1143. cmdlvl = 0; /* Initialize the command stack */
  1144. xcmdsrc = CMD_KB;
  1145. cmdstk[cmdlvl].src = CMD_KB; /* Source is console */
  1146. cmdstk[cmdlvl].lvl = 0; /* Level is 0 */
  1147. cmdstk[cmdlvl].ccflgs = 0; /* No flags */
  1148. #endif /* NOSPL */
  1149. tlevel = -1; /* Take file level = keyboard */
  1150. for (i = 0; i < MAXTAKE; i++) /* Initialize command file names */
  1151. tfnam[i] = NULL;
  1152. cmsetp(ckprompt); /* Set up C-Kermit's prompt */
  1153. /* Can't set IKSD prompt here since */
  1154. /* we do not yet know if we are IKSD */
  1155. #ifndef NOSPL
  1156. initmac(); /* Initialize macro table */
  1157. /* Predefine built-in one-line macros */
  1158. addmac("ibm-linemode",m_ibm); /* IBM-LINEMODE */
  1159. addmac("fatal",m_fat); /* FATAL macro */
  1160. y = addmac("fast",m_fast); /* FAST macro */
  1161. addmac("cautious",m_cautious); /* CAUTIOUS macro */
  1162. addmac("robust",m_robust); /* ROBUST macro */
  1163. #ifdef OS2
  1164. addmac("manual",m_manual); /* MANUAL macro */
  1165. #endif /* OS2 */
  1166. #ifdef VMS
  1167. addmac("purge",m_purge); /* PURGE macro */
  1168. #endif /* VMS */
  1169. /*
  1170. Predefine built-in multiline macros; these are top-level commands
  1171. that are implemented internally as macros. NOTE: When adding a new
  1172. one of these, remember to update the END and RETURN commands to
  1173. account for it, or else END and RETURN from within it won't work right.
  1174. */
  1175. x = addmmac("_forx",for_def); /* FOR macro */
  1176. if (x > -1) mactab[x].flgs = CM_INV;
  1177. x = addmmac("_forz",foz_def); /* Other FOR macro */
  1178. if (x > -1) mactab[x].flgs = CM_INV;
  1179. x = addmmac("_xif",xif_def); /* XIF macro */
  1180. if (x > -1) mactab[x].flgs = CM_INV;
  1181. x = addmmac("_while",whil_def); /* WHILE macro */
  1182. if (x > -1) mactab[x].flgs = CM_INV;
  1183. x = addmmac("_switx",sw_def); /* SWITCH macro */
  1184. if (x > -1) mactab[x].flgs = CM_INV;
  1185. /* Fill in command-line argument vector */
  1186. sprintf(vnambuf,"\\&@[%d]",xargs); /* SAFE */
  1187. if (inserver) { /* But hidden in IKSD */
  1188. y = -1;
  1189. xargs = 0;
  1190. } else
  1191. y = arraynam(vnambuf,&x,&z); /* goes in array \&@[] */
  1192. tmpbuf[0] = NUL;
  1193. if (y > -1) {
  1194. int j = -1;
  1195. int yy = 0;
  1196. dclarray((char)x,z); /* Declare the array */
  1197. #ifndef NOTAKEARGS
  1198. /* Macro argument vector */
  1199. sprintf(vnambuf,"\\&_[%d]",z); /* SAFE */
  1200. yy = arraynam(vnambuf,&x,&z); /* goes in array \&_[] */
  1201. if (yy > -1) /* Name is OK */
  1202. dclarray((char)x,z); /* Declare the array */
  1203. #endif /* NOTAKEARGS */
  1204. skip = 0;
  1205. for (i = 0; i < xargs; i++) { /* Fill the arrays */
  1206. sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
  1207. addmac(vnambuf,xargv[i]);
  1208. if (cfilef && i == 0)
  1209. continue;
  1210. #ifdef KERBANG
  1211. if (skip) {
  1212. j = 0;
  1213. skip = 0;
  1214. continue;
  1215. }
  1216. #endif /* KERBANG */
  1217. if (j < 0 && /* Assign items after "=" or "--"*/
  1218. (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
  1219. ) {
  1220. j = 0; /* to \%1..\%9 */
  1221. #ifdef KERBANG
  1222. } else if (j < 0 &&
  1223. (!strcmp(xargv[i],"+") ||
  1224. !strncmp(xargv[i],"+ ",2) ||
  1225. !strncmp(xargv[i],"+\t",2))
  1226. ) {
  1227. skip = 1;
  1228. continue;
  1229. #endif /* KERBANG */
  1230. } else if (j > -1) {
  1231. j++;
  1232. if (j <= 9) {
  1233. vnambuf[0] = '\\';
  1234. vnambuf[1] = '%';
  1235. vnambuf[2] = (char)(j+'0');
  1236. vnambuf[3] = NUL;
  1237. addmac(vnambuf,xargv[i]);
  1238. }
  1239. if (yy > -1) {
  1240. char c, * p;
  1241. int flag = 0;
  1242. p = xargv[i];
  1243. makestr(&(toparg[j]),p);
  1244. while ((c = *p++)) { if (c == SP) { flag++; break; } }
  1245. if (flag)
  1246. ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1247. ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
  1248. if (flag)
  1249. ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
  1250. ckstrncat(tmpbuf," ",TMPBUFSIZ);
  1251. }
  1252. }
  1253. }
  1254. if (cfilef) {
  1255. addmac("\\%0",cmdfil);
  1256. if (yy > -1)
  1257. makestr(&(toparg[0]),cmdfil);
  1258. } else {
  1259. addmac("\\%0",xargv[0]);
  1260. if (yy > -1)
  1261. makestr(&(toparg[0]),xargv[0]);
  1262. }
  1263. if (yy > -1) {
  1264. topargc = (j < 0) ? 1 : j + 1;
  1265. topxarg = toparg;
  1266. #ifdef COMMENT
  1267. /* This needs work */
  1268. if (!cfilef)
  1269. makestr(&topline,tmpbuf);
  1270. #endif /* COMMENT */
  1271. } else {
  1272. topargc = 0;
  1273. topxarg = NULL;
  1274. }
  1275. a_dim[0] = topargc - 1;
  1276. a_ptr[0] = topxarg;
  1277. debug(F111,"a_dim[0]","A",a_dim[0]);
  1278. }
  1279. *vnambuf = NUL;
  1280. #endif /* NOSPL */
  1281. luinit(); /* Initialize lookup() cache */
  1282. /* Get our home directory now. This needed in lots of places. */
  1283. cmdinited = 1;
  1284. }
  1285. #ifdef NT
  1286. _PROTOTYP(char * GetAppData,(int));
  1287. #endif /* NT */
  1288. VOID
  1289. doinit() {
  1290. #ifdef CKROOT
  1291. extern int ckrooterr;
  1292. #endif /* CKROOT */
  1293. int x = 0, ok = 0;
  1294. #ifdef OS2
  1295. char * ptr = 0;
  1296. #endif /* OS2 */
  1297. if (!cmdinited)
  1298. cmdini();
  1299. #ifdef MAC
  1300. return; /* Mac Kermit has no init file */
  1301. #else /* !MAC */
  1302. /* If skipping init file ('-Y' on Kermit command line), return now. */
  1303. if (noinit) {
  1304. kermrc[0] = '\0';
  1305. inidir[0] = '\0';
  1306. /*
  1307. But returning from here results in inidir[] never being set to anything.
  1308. Instead it should be set to wherever the init file *would* have been
  1309. executed from. So this bit of code should be removed, and then we should
  1310. sprinkle "if (noinit)" tests throughout the following code until we have
  1311. set inidir[], and then return without actually taking the init file.
  1312. */
  1313. return;
  1314. }
  1315. #ifdef OS2
  1316. /*
  1317. The -y init file must be fully specified or in the current directory.
  1318. KERMRC is looked for via INIT, DPATH and PATH in that order. Finally, our
  1319. own executable file path is taken and the .EXE suffix is replaced by .INI
  1320. and this is tried as the initialization file.
  1321. */
  1322. #ifdef CK_LOGIN
  1323. debug(F101,"doinit inserver","",inserver);
  1324. debug(F101,"doinit isguest","",isguest);
  1325. debug(F110,"doinit anonfile",anonfile,0);
  1326. if (isguest && anonfile) {
  1327. ckstrncpy(line, anonfile, LINBUFSIZ+1);
  1328. } else
  1329. #endif /* CK_LOGIN */
  1330. if (rcflag) {
  1331. ckstrncpy(line,kermrc,LINBUFSIZ+1);
  1332. #ifdef CK_LOGIN
  1333. } else if (inserver) {
  1334. char * appdata = NULL;
  1335. #ifdef NT
  1336. appdata = GetAppData(1);
  1337. if ( appdata ) {
  1338. ckmakmsg(line,LINBUFSIZ+1,appdata,
  1339. "Kermit 95/k95.ini",NULL,NULL);
  1340. if ( zchki(line) < 0 )
  1341. line[0] = '\0';
  1342. }
  1343. if (line[0] == 0) {
  1344. appdata = GetAppData(0);
  1345. if ( appdata ) {
  1346. ckmakmsg(line,LINBUFSIZ+1,appdata,
  1347. "Kermit 95/k95.ini",NULL,NULL);
  1348. if ( zchki(line) < 0 )
  1349. line[0] = '\0';
  1350. }
  1351. }
  1352. #endif /* NT */
  1353. if (line[0] == 0) {
  1354. appdata = zhome();
  1355. if ( appdata ) {
  1356. ckmakmsg(line,LINBUFSIZ+1,appdata,
  1357. #ifdef NT
  1358. "k95.ini",
  1359. #else /* NT */
  1360. "k2.ini",
  1361. #endif /* NT */
  1362. NULL,NULL);
  1363. if ( zchki(line) < 0 )
  1364. line[0] = '\0';
  1365. }
  1366. }
  1367. debug(F110,"doinit inserver inifile",line,0);
  1368. #endif /* CK_LOGIN */
  1369. } else {
  1370. char * env = 0;
  1371. #ifdef NT
  1372. env = getenv("K95.KSC");
  1373. #else
  1374. env = getenv("K2.KSC");
  1375. #endif /* NT */
  1376. if (!env) {
  1377. #ifdef NT
  1378. env = getenv("K95.INI");
  1379. #else
  1380. env = getenv("K2.INI");
  1381. #endif /* NT */
  1382. }
  1383. if (!env)
  1384. env = getenv("CKERMIT.INI");
  1385. if (!env)
  1386. env = getenv("CKERMIT_INI");
  1387. line[0] = '\0';
  1388. debug(F110,"doinit env",env,0);
  1389. if (env)
  1390. ckstrncpy(line,env,LINBUFSIZ+1);
  1391. #ifdef NT
  1392. if (line[0] == 0) {
  1393. env = GetAppData(1);
  1394. if ( env ) {
  1395. ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1396. if ( zchki(line) < 0 )
  1397. line[0] = '\0';
  1398. }
  1399. }
  1400. if (line[0] == 0) {
  1401. env = GetAppData(0);
  1402. if ( env ) {
  1403. ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
  1404. if ( zchki(line) < 0 )
  1405. line[0] = '\0';
  1406. }
  1407. }
  1408. #endif /* NT */
  1409. if (line[0] == 0) {
  1410. env = zhome();
  1411. if ( env ) {
  1412. ckmakmsg(line,LINBUFSIZ+1,env,
  1413. #ifdef NT
  1414. "k95.ini",
  1415. #else /* NT */
  1416. "k2.ini",
  1417. #endif /* NT */
  1418. NULL,NULL);
  1419. if ( zchki(line) < 0 )
  1420. line[0] = '\0';
  1421. }
  1422. }
  1423. if (line[0] == 0)
  1424. _searchenv(kermrc,"INIT",line);
  1425. if (line[0] == 0)
  1426. _searchenv(kermrc,"DPATH",line);
  1427. if (line[0] == 0)
  1428. _searchenv(kermrc,"PATH",line);
  1429. if (line[0] == 0) {
  1430. char *pgmptr = GetLoadPath();
  1431. if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1432. lp = strrchr(pgmptr, '\\');
  1433. if (lp) {
  1434. strncpy(line, pgmptr, lp - pgmptr);
  1435. #ifdef NT
  1436. strcpy(line + (lp - pgmptr), "/k95.ini");
  1437. #else /* NT */
  1438. strcpy(line + (lp - pgmptr), "/k2.ini");
  1439. #endif /* NT */
  1440. } else {
  1441. lp = strrchr(pgmptr, '.');
  1442. if (lp) {
  1443. strncpy(line, pgmptr, lp - pgmptr);
  1444. strcpy(line + (lp - pgmptr), ".ini");
  1445. }
  1446. }
  1447. }
  1448. }
  1449. }
  1450. #ifdef CKROOT
  1451. if (!zinroot(line)) {
  1452. debug(F110,"doinit setroot violation",line,0);
  1453. return;
  1454. }
  1455. #endif /* CKROOT */
  1456. debug(F110,"doinit fopen()",line,0);
  1457. if ((tfile[0] = fopen(line,"r")) != NULL) {
  1458. ok = 1;
  1459. tlevel = 0;
  1460. tfline[tlevel] = 0;
  1461. tfblockstart[tlevel] = 1;
  1462. if (tfnam[tlevel] = malloc(strlen(line)+1))
  1463. strcpy(tfnam[tlevel],line); /* safe */
  1464. #ifndef NOSPL
  1465. cmdlvl++;
  1466. xcmdsrc = CMD_TF;
  1467. cmdstk[cmdlvl].src = CMD_TF;
  1468. cmdstk[cmdlvl].lvl = tlevel;
  1469. cmdstk[cmdlvl].ccflgs = 0;
  1470. ifcmd[cmdlvl] = 0;
  1471. iftest[cmdlvl] = 0;
  1472. count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
  1473. intime[cmdlvl] = intime[cmdlvl-1];
  1474. inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1475. takerr[cmdlvl] = takerr[cmdlvl-1];
  1476. merror[cmdlvl] = merror[cmdlvl-1];
  1477. xquiet[cmdlvl] = quiet;
  1478. xvarev[cmdlvl] = vareval;
  1479. #endif /* NOSPL */
  1480. debug(F110,"doinit init file",line,0);
  1481. } else {
  1482. debug(F100,"doinit no init file","",0);
  1483. }
  1484. ckstrncpy(kermrc,line,KERMRCL);
  1485. for (ptr = kermrc; *ptr; ptr++) /* Convert backslashes to slashes */
  1486. if (*ptr == '\\')
  1487. *ptr = '/';
  1488. #else /* not OS2 */
  1489. lp = line;
  1490. lp[0] = '\0';
  1491. debug(F101,"doinit rcflag","",rcflag);
  1492. #ifdef GEMDOS
  1493. zkermini(line, rcflag, kermrc);
  1494. #else
  1495. #ifdef VMS
  1496. {
  1497. int x;
  1498. x = zkermini(line,LINBUFSIZ,kermrc);
  1499. debug(F111,"CUSTOM zkermini",line,x);
  1500. if (x == 0)
  1501. line[0] = NUL;
  1502. }
  1503. #else /* not VMS */
  1504. #ifdef CK_LOGIN
  1505. debug(F101,"doinit isguest","",isguest);
  1506. if (isguest)
  1507. ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
  1508. else
  1509. #endif /* CK_LOGIN */
  1510. if (rcflag) { /* If init file name from cmd line */
  1511. ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
  1512. } else { /* otherwise... */
  1513. #ifdef CK_INI_A /* If we've a system-wide init file */
  1514. /* And it takes precedence over the user's... */
  1515. ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
  1516. if (zchki(lp) < 0) { /* (if it exists...) */
  1517. #endif /* CK_INI_A */
  1518. char * homdir;
  1519. char * env = 0;
  1520. line[0] = NUL;
  1521. /* Add support for environment variable */
  1522. env = getenv("CKERMIT.INI");
  1523. if (!env)
  1524. env = getenv("CKERMIT_INI");
  1525. if (env)
  1526. ckstrncpy(lp,env,KERMRCL);
  1527. if (lp[0] == 0) {
  1528. homdir = zhome();
  1529. if (homdir) { /* Home directory for init file. */
  1530. ckstrncpy(lp,homdir,KERMRCL);
  1531. #ifdef STRATUS
  1532. ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
  1533. #else
  1534. if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
  1535. #endif /* STRATUS */
  1536. }
  1537. ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
  1538. }
  1539. #ifdef CK_INI_A
  1540. }
  1541. #endif /* CK_INI_A */
  1542. #ifdef CK_INI_B /* System-wide init defined? */
  1543. /* But user's ini file takes precedence */
  1544. if (zchki(lp) < 0) /* If user doesn't have her own, */
  1545. ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
  1546. #endif /* CK_INI_B */
  1547. }
  1548. #endif /* VMS */
  1549. #endif /* GEMDOS */
  1550. #ifdef AMIGA
  1551. reqoff(); /* Disable requestors */
  1552. #endif /* AMIGA */
  1553. #ifdef USE_CUSTOM
  1554. /* If no init file was found, execute the customization file */
  1555. debug(F111,"CUSTOM 1",line,rcflag);
  1556. if ((!line[0] || zchki(line) < 0) && !rcflag) {
  1557. int x;
  1558. #ifdef OS2
  1559. x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
  1560. debug(F111,"CUSTOM 2",line,x);
  1561. if (zchki(line) < 0) {
  1562. x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
  1563. debug(F111,"CUSTOM 3",line,x);
  1564. }
  1565. #else /* OS2 */
  1566. x = ckstrncpy(line,zhome(),LINBUFSIZ);
  1567. #ifndef VMS
  1568. /* VMS zhome() returns "SYS$LOGIN:" */
  1569. if (line[x-1] != DIRSEP) {
  1570. line[x++] = DIRSEP;
  1571. line[x] = NUL;
  1572. }
  1573. #endif /* VMS */
  1574. x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
  1575. debug(F111,"CUSTOM 4",line,x);
  1576. #endif /* OS2 */
  1577. }
  1578. debug(F110,"CUSTOM 5",line,0);
  1579. #endif /* USE_CUSTOM */
  1580. #ifdef CKROOT
  1581. if (!zinroot(line)) {
  1582. debug(F110,"doinit setroot violation",line,0);
  1583. return;
  1584. }
  1585. #endif /* CKROOT */
  1586. debug(F110,"doinit ini file is",line,0);
  1587. if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
  1588. ok = 1;
  1589. tlevel = 0;
  1590. tfline[tlevel] = 0;
  1591. tfblockstart[tlevel] = 1;
  1592. if ((tfnam[tlevel] = malloc(strlen(line)+1)))
  1593. strcpy(tfnam[tlevel],line); /* safe */
  1594. ckstrncpy(kermrc,line,KERMRCL);
  1595. #ifndef NOSPL
  1596. cmdlvl++;
  1597. ifcmd[cmdlvl] = 0;
  1598. iftest[cmdlvl] = 0;
  1599. count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
  1600. intime[cmdlvl] = intime[cmdlvl-1];
  1601. inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1602. takerr[cmdlvl] = takerr[cmdlvl-1];
  1603. merror[cmdlvl] = merror[cmdlvl-1];
  1604. xquiet[cmdlvl] = quiet;
  1605. xvarev[cmdlvl] = vareval;
  1606. debug(F101,"doinit open ok","",cmdlvl);
  1607. xcmdsrc = CMD_TF;
  1608. cmdstk[cmdlvl].src = CMD_TF;
  1609. cmdstk[cmdlvl].lvl = tlevel;
  1610. cmdstk[cmdlvl].ccflgs = 0;
  1611. #endif /* NOSPL */
  1612. } else if (rcflag) {
  1613. /* Print an error message only if a specific file was asked for. */
  1614. printf("?%s - %s\n", ck_errstr(), line);
  1615. }
  1616. #ifdef datageneral
  1617. /* If CKERMIT.INI not found in home directory, look in searchlist */
  1618. if (/* homdir && */ (tlevel < 0)) {
  1619. ckstrncpy(lp,kermrc,LINBUFSIZ);
  1620. if ((tfile[0] = fopen(line,"r")) != NULL) {
  1621. ok = 1;
  1622. tlevel = 0;
  1623. tfline[tlevel] = 0;
  1624. tfblockstart[tlevel] = 1;
  1625. if (tfnam[tlevel] = malloc(strlen(line)+1))
  1626. strcpy(tfnam[tlevel],line); /* safe */
  1627. #ifndef NOSPL
  1628. cmdlvl++;
  1629. xcmdsrc = CMD_TF;
  1630. cmdstk[cmdlvl].src = CMD_TF;
  1631. cmdstk[cmdlvl].lvl = tlevel;
  1632. cmdstk[cmdlvl].ccflgs = 0;
  1633. ifcmd[cmdlvl] = 0;
  1634. iftest[cmdlvl] = 0;
  1635. count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
  1636. intime[cmdlvl] = intime[cmdlvl-1];
  1637. inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1638. takerr[cmdlvl] = takerr[cmdlvl-1];
  1639. merror[cmdlvl] = merror[cmdlvl-1];
  1640. xquiet[cmdlvl] = quiet;
  1641. xvarev[cmdlvl] = vareval;
  1642. #endif /* NOSPL */
  1643. }
  1644. }
  1645. #endif /* datageneral */
  1646. #ifdef AMIGA /* Amiga... */
  1647. reqpop(); /* Restore requestors */
  1648. #endif /* AMIGA */
  1649. #endif /* OS2 */
  1650. #endif /* MAC */
  1651. /* Assign value to inidir */
  1652. if (!ok) {
  1653. inidir[0] = NUL;
  1654. } else {
  1655. ckstrncpy(inidir, kermrc, CCHMAXPATH);
  1656. x = strlen(inidir);
  1657. if (x > 0) {
  1658. int i;
  1659. for (i = x - 1; i > 0; i-- ) {
  1660. if (ISDIRSEP(inidir[i])) {
  1661. inidir[i+1] = NUL;
  1662. break;
  1663. }
  1664. }
  1665. }
  1666. #ifdef NT
  1667. GetShortPathName(inidir,inidir,CCHMAXPATH);
  1668. #endif /* NT */
  1669. }
  1670. }
  1671. VOID
  1672. doiksdinit() {
  1673. #ifdef CK_SSL
  1674. /* IKSD doesn't request client certs */
  1675. ssl_verify_flag = SSL_VERIFY_NONE;
  1676. #endif /* CK_SSL */
  1677. if (!cmdinited)
  1678. cmdini();
  1679. #ifdef IKSDCONF
  1680. #ifdef OS2
  1681. line[0] = '\0';
  1682. _searchenv(iksdconf,"INIT",line);
  1683. if (line[0] == 0)
  1684. _searchenv(iksdconf,"DPATH",line);
  1685. if (line[0] == 0)
  1686. _searchenv(iksdconf,"PATH",line);
  1687. if (line[0] == 0) {
  1688. char *pgmptr = GetLoadPath();
  1689. if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
  1690. lp = strrchr(pgmptr, '\\');
  1691. if (lp) {
  1692. strncpy(line, pgmptr, lp - pgmptr);
  1693. strcpy(line + (lp - pgmptr), "\\");
  1694. strcpy(line + (lp - pgmptr + 1), iksdconf);
  1695. } else {
  1696. lp = strrchr(pgmptr, '.');
  1697. if (lp) {
  1698. strncpy(line, pgmptr, lp - pgmptr);
  1699. strcpy(line + (lp - pgmptr), ".ksc");
  1700. }
  1701. }
  1702. }
  1703. }
  1704. debug(F110,"doiksdinit() line",line,0);
  1705. tfile[0] = fopen(line,"r");
  1706. #else /* OS2 */
  1707. tfile[0] = fopen(iksdconf,"r");
  1708. #endif /* OS2 */
  1709. if (tfile[0] != NULL) {
  1710. tlevel = 0;
  1711. tfline[tlevel] = 0;
  1712. tfblockstart[tlevel] = 1;
  1713. #ifdef OS2
  1714. if (tfnam[tlevel] = malloc(strlen(line)+1))
  1715. strcpy(tfnam[tlevel],line);
  1716. #else /* OS2 */
  1717. if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
  1718. strcpy(tfnam[tlevel],iksdconf);
  1719. #endif /* OS2 */
  1720. #ifndef NOSPL
  1721. cmdlvl++;
  1722. xcmdsrc = CMD_TF;
  1723. cmdstk[cmdlvl].src = CMD_TF;
  1724. cmdstk[cmdlvl].lvl = tlevel;
  1725. cmdstk[cmdlvl].ccflgs = 0;
  1726. ifcmd[cmdlvl] = 0;
  1727. iftest[cmdlvl] = 0;
  1728. count[cmdlvl] = count[cmdlvl-1]; /* Inherit from previous level */
  1729. intime[cmdlvl] = intime[cmdlvl-1];
  1730. inpcas[cmdlvl] = inpcas[cmdlvl-1];
  1731. takerr[cmdlvl] = takerr[cmdlvl-1];
  1732. merror[cmdlvl] = merror[cmdlvl-1];
  1733. xquiet[cmdlvl] = quiet;
  1734. xvarev[cmdlvl] = vareval;
  1735. #endif /* NOSPL */
  1736. debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
  1737. } else {
  1738. debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
  1739. }
  1740. #endif /* IKSDCONF */
  1741. }
  1742. #ifndef NOSPL
  1743. /*
  1744. G E T N C M
  1745. Get next command from current macro definition. Command is copied
  1746. into string pointed to by argument s, max length n. Returns:
  1747. 0 if a string was copied;
  1748. -1 if there was no string to copy.
  1749. */
  1750. int
  1751. getncm(s,n) char *s; int n; {
  1752. int y = 0; /* Character counter */
  1753. int quote = 0;
  1754. int kp = 0; /* Brace up-down counter */
  1755. int pp = 0; /* Parenthesis up-down counter */
  1756. #ifndef NODQMACRO
  1757. int dq = 0; /* Doublequote counter */
  1758. #endif /* NODQMACRO */
  1759. char *s2; /* Copy of destination pointer */
  1760. s2 = s; /* Initialize string pointers */
  1761. *s = NUL; /* and destination buffer */
  1762. /* debug(F010,"getncm entry",macp[maclvl],0); */
  1763. for (y = 0; /* Loop for n bytes max */
  1764. macp[maclvl] && *macp[maclvl] && y < n;
  1765. y++, s++, macp[maclvl]++) {
  1766. *s = *macp[maclvl]; /* Get next char from macro def */
  1767. #ifndef COMMENT
  1768. /*
  1769. This is to allow quoting of parentheses, commas, etc, in function
  1770. arguments, but it breaks just about everything else. DON'T REMOVE THIS
  1771. COMMENT! (Otherwise you'll wind up adding the same code again and breaking
  1772. everything again.) <-- The preceding warning should be obsolete since the
  1773. statements below have been fixed, but in case of fire, remove the "n" from
  1774. the <#>ifndef above. NEW WARNING: code added 12 Apr 2002 to exempt the
  1775. opening brace in \{nnn} from being treated as a quoted brace.
  1776. */
  1777. if (!quote && *s == CMDQ) {
  1778. quote = 1;
  1779. continue;
  1780. }
  1781. if (quote) {
  1782. int notquote = 0;
  1783. quote = 0;
  1784. if (*s == '{') { /* Check for \{nnn} (8.0.203) */
  1785. char c, * p;
  1786. p = macp[maclvl] + 1;
  1787. while ((c = *p++)) {
  1788. if (isdigit(c))
  1789. continue;
  1790. else if (c == '}') {
  1791. notquote++;
  1792. break;
  1793. } else {
  1794. break;
  1795. }
  1796. }
  1797. }
  1798. if (notquote == 0)
  1799. continue;
  1800. }
  1801. #endif /* COMMENT */
  1802. /*
  1803. Allow braces around macro definition to prevent commas from being turned to
  1804. end-of-lines and also treat any commas within parens as text so that
  1805. multiple-argument functions won't cause the command to break prematurely.
  1806. 19 Oct 2001: Similar treatment was added for doublequotes, so
  1807. define foo { echo "one, two, three" }
  1808. would work as expected. This doesn't seem to have broken anything but
  1809. if something comes up later, rebuild with NODQMACRO defined.
  1810. */
  1811. if (*s == '{') kp++; /* Count braces */
  1812. if (*s == '}' && kp > 0) kp--;
  1813. if (*s == '(') pp++; /* Count parentheses. */
  1814. if (*s == ')' && pp > 0) pp--;
  1815. #ifndef NODQMACRO
  1816. #ifndef COMMENT
  1817. /* Too many false positives */
  1818. /* No, not really -- this is indeed the best we can do */
  1819. /* Reverted to this method Sun May 11 18:43:45 2003 */
  1820. if (*s == '"') dq = 1 - dq; /* Account for doublequotes */
  1821. #else /* Fri Apr 4 13:21:29 2003 */
  1822. /* The code below breaks the SWITCH statement */
  1823. /* There is no way to make this work -- it would require */
  1824. /* building in all the knowledge of command parser. */
  1825. if (dblquo && (*s == '"')) { /* Have doublequote */
  1826. if (dq == 1) { /* Close quote only if... */
  1827. if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
  1828. (!*(macp[maclvl]+1)) || /* at end or ... */
  1829. /* Next char is command separator... */
  1830. /* Sun May 11 17:24:12 2003 */
  1831. (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
  1832. )
  1833. dq = 0; /* Close the quote */
  1834. } else if (dq == 0) {
  1835. /* Open quote only if at beginning or preceded by space */
  1836. if (s > s2) {
  1837. if (*(s-1) == SP)
  1838. dq = 1;
  1839. } else if (s == s2) {
  1840. dq = 1;
  1841. }
  1842. }
  1843. }
  1844. #endif /* COMMENT */
  1845. #endif /* NODQMACRO */
  1846. if (*s == ',' && pp <= 0 && kp <= 0
  1847. #ifndef NODQMACRO
  1848. && dq == 0
  1849. #endif /* NODQMACRO */
  1850. ) {
  1851. macp[maclvl]++; /* Comma not in {} or () */
  1852. /* debug(F110,"next cmd",s,0); */
  1853. kp = pp = 0; /* so we have the next command */
  1854. break;
  1855. }
  1856. } /* Reached end. */
  1857. #ifdef COMMENT
  1858. /* DON'T DO THIS - IT BREAKS EVERYTHING */
  1859. *s = NUL;
  1860. #endif /* COMMENT */
  1861. if (*s2 == NUL) { /* If nothing was copied, */
  1862. /* debug(F100,"getncm eom","",0); */
  1863. popclvl(); /* pop command level. */
  1864. return(-1);
  1865. } else { /* otherwise, tack CR onto end */
  1866. *s++ = CR;
  1867. *s = '\0';
  1868. /* debug(F110,"getncm OK",s,0); */
  1869. if (mecho && pflag) /* If MACRO ECHO ON, echo the cmd */
  1870. printf("%s\n",s2);
  1871. }
  1872. return(0);
  1873. }
  1874. /* D O M A C -- Define and then execute a macro */
  1875. int
  1876. domac(name, def, flags) char *name, *def; int flags; {
  1877. int x, m;
  1878. #ifndef NOLOCAL
  1879. #ifdef OS2
  1880. extern int term_io;
  1881. int term_io_sav = term_io;
  1882. term_io = 0; /* Disable Terminal Emulator I/O */
  1883. #endif /* OS2 */
  1884. #endif /* NOLOCAL */
  1885. m = maclvl; /* Current macro stack level */
  1886. x = addmac(name, def); /* Define a new macro */
  1887. if (x > -1) { /* If successful, */
  1888. dodo(x,NULL,flags); /* start it (increments maclvl). */
  1889. while (maclvl > m) { /* Keep going till done with it, */
  1890. debug(F101,"domac loop maclvl 1","",maclvl);
  1891. sstate = (CHAR) parser(1); /* parsing & executing each command, */
  1892. debug(F101,"domac loop maclvl 2","",maclvl);
  1893. if (sstate) proto(); /* including protocol commands. */
  1894. }
  1895. debug(F101,"domac loop exit maclvl","",maclvl);
  1896. }
  1897. #ifndef NOLOCAL
  1898. #ifdef OS2
  1899. term_io = term_io_sav;
  1900. #endif /* OS2 */
  1901. #endif /* NOLOCAL */
  1902. return(success);
  1903. }
  1904. #endif /* NOSPL */
  1905. /*
  1906. G E T N C T
  1907. Get next command from TAKE (command) file.
  1908. Call with:
  1909. s Pointer to buffer to read into
  1910. n Length of buffer
  1911. f File descriptor of file to read from
  1912. flag 0 == keep line terminator on and allow continuation
  1913. 1 == discard line terminator and don't allow continuation
  1914. Call with flag == 0 to read a command from a TAKE file;
  1915. Call with flag != 0 to read a line from a dialing or network directory.
  1916. In both cases, trailing comments and/or trailing whitespace is/are stripped.
  1917. If flag == 0, continued lines are combined into one line. A continued line
  1918. is one that ends in hypen, or any line in a "block", which starts with "{"
  1919. at the end of a line and ends with a matching "}" at the beginning of a
  1920. subsequent line; blocks may be nested.
  1921. Returns:
  1922. 0 if a string was copied,
  1923. -1 on EOF,
  1924. -2 on malloc failure
  1925. -3 if line is not properly terminated
  1926. -4 if (possibly continued) line is too long.
  1927. */
  1928. static int lpxlen = 0;
  1929. int
  1930. getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
  1931. int i = 0, len = 0, buflen = 0;
  1932. char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
  1933. char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
  1934. char * prev = NULL;
  1935. int bc = 0; /* Block counter */
  1936. int firstread = 1;
  1937. s2 = s; /* Remember original pointer */
  1938. prev = s2; /* Here too */
  1939. buflen = n; /* Remember original buffer length */
  1940. if (n < 0)
  1941. return(-2);
  1942. /* Allocate a line buffer only if we don't have one that's big enough */
  1943. debug(F111,"getnct",ckitoa(lpxlen),n);
  1944. if (lpx && (n > lpxlen)) { /* Have one already */
  1945. debug(F101,"getnct new buffer","",lpxlen);
  1946. free(lpx); /* But it's not big enough */
  1947. lpx = NULL; /* Free current one */
  1948. lpxlen = 0;
  1949. }
  1950. if (!lpx) { /* Get new one */
  1951. if (!(lpx = (char *) malloc(n))) {
  1952. debug(F101,"getnct malloc failure","",0);
  1953. printf("?Memory allocation failure [getnct:%d]\n",n);
  1954. return(-2);
  1955. }
  1956. lpxlen = n;
  1957. }
  1958. lp2 = lpx;
  1959. #ifdef KLUDGE
  1960. /* NOTE: No longer used as of 14 Aug 2000 */
  1961. lp2++;
  1962. #endif /* KLUDGE */
  1963. while (1) { /* Loop to read lines from file */
  1964. debug(F101,"getnct while (1)","",n);
  1965. if (fgets(lp2,n,f) == NULL) { /* Read a line into lp2 */
  1966. debug(F110,"getnct EOF",s2,0); /* EOF */
  1967. free(lpx); /* Free temporary storage */
  1968. lpx = NULL;
  1969. *s = NUL; /* Make destination be empty */
  1970. return(-1); /* Return failure code */
  1971. }
  1972. if (firstread) { /* Beginning of a block or statement */
  1973. tfblockstart[tlevel] = tfline[tlevel];
  1974. firstread = 0;
  1975. }
  1976. #ifndef NODIAL
  1977. if (flag) /* Count this line */
  1978. dirline++;
  1979. else
  1980. #endif /* NODIAL */
  1981. tfline[tlevel]++;
  1982. len = strlen(lp2) - 1; /* Position of line terminator */
  1983. if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
  1984. lp2[++len] = '\n'; /* that is not a newline */
  1985. lp2[len] = NUL;
  1986. }
  1987. debug(F010,"getnct",lp2,0);
  1988. if (len < 0)
  1989. len = 0;
  1990. if (techo && pflag) { /* If TAKE ECHO ON, */
  1991. if (flag) {
  1992. printf("%3d. %s", /* echo it this line. */
  1993. #ifndef NODIAL
  1994. flag ? dirline :
  1995. #endif /* NODIAL */
  1996. tfline[tlevel],
  1997. lp2
  1998. );
  1999. } else {
  2000. printf("%3d. %3d. %s", /* echo it this line. */
  2001. tfline[tlevel],
  2002. tfblockstart[tlevel],
  2003. lp2
  2004. );
  2005. }
  2006. }
  2007. lp3 = lp2; /* Working pointer */
  2008. i = len; /* Get first nonwhitespace character */
  2009. while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
  2010. i--;
  2011. lp3++;
  2012. }
  2013. if (i == 0 && bc > 0) /* Blank line in {...} block */
  2014. continue;
  2015. /* Isolate, remove, and check terminator */
  2016. c = lp2[len]; /* Value of line terminator */
  2017. /* debug(F101,"getnct terminator","",c); */
  2018. if (c < LF || c > CR) { /* It's not a terminator */
  2019. /* debug(F111,"getnct bad line",lp2,c); */
  2020. if (feof(f) && len > 0 && len < n) {
  2021. /* Kludge Alert... */
  2022. if (!quiet)
  2023. printf("WARNING: Last line of %s lacks terminator\n",
  2024. s2 == cmdbuf ? "command file" : "directory file");
  2025. c = lp2[++len] = '\n'; /* No big deal - supply one. */
  2026. } else { /* Something's wrong, fail. */
  2027. free(lpx);
  2028. lpx = NULL;
  2029. return(-3);
  2030. }
  2031. }
  2032. /* Trim trailing whitespace */
  2033. for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
  2034. ;
  2035. /* debug(F101,"getnct i","",i); */
  2036. lp2[i+1] = NUL; /* Terminate the string */
  2037. /* debug(F110,"getnct lp2",lp2,0); */
  2038. lp = lp2; /* Make a working pointer */
  2039. /* Remove trailing or full-line comment */
  2040. while ((cc = *lp)) {
  2041. if (cc == ';' || cc == '#') { /* Comment introducer? */
  2042. if (lp == lp2) { /* First char on line */
  2043. *lp = NUL;
  2044. break;
  2045. } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
  2046. lp--;
  2047. *lp = NUL; /* Or preceded by whitespace */
  2048. break;
  2049. }
  2050. }
  2051. lp++;
  2052. }
  2053. if (lp > lp2)
  2054. lp--; /* Back up over the NUL */
  2055. /* Now trim any space that preceded the comment */
  2056. while ((*lp == SP || *lp == HT) && lp >= lp2) {
  2057. *lp = NUL;
  2058. if (lp <= lp2)
  2059. break;
  2060. lp--;
  2061. }
  2062. /* debug(F110,"getnct comment trimmed",lp2,0); */
  2063. len = strlen(lp2); /* Length after trimming */
  2064. if (n - len < 2) { /* Check remaining space */
  2065. debug(F111,"getnct command too long",s2,buflen);
  2066. printf("?Line too long, maximum length: %d.\n",buflen);
  2067. free(lpx);
  2068. return(-4);
  2069. }
  2070. ccl = (len > 0) ? lp2[len-1] : 0; /* Last character in line */
  2071. ccx = (len > 1) ? lp2[len-2] : 0; /* Penultimate char in line */
  2072. #ifdef COMMENT
  2073. /* Line containing only whitespace and ,- */
  2074. if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
  2075. continue;
  2076. #endif /* COMMENT */
  2077. #ifdef KLUDGE
  2078. /*
  2079. If it is a command and it begins with a token (like ! or .) that is not
  2080. followed by a space, insert a space now; otherwise cmkey() can get mighty
  2081. confused.
  2082. */
  2083. if (s == s2 && !flag) {
  2084. char *p = toktab;
  2085. while (*p) {
  2086. if (*p == *lp3 && *(p+1) != SP) {
  2087. debug(F110,"getnct token",p,0);
  2088. *lp3-- = SP;
  2089. *lp3 = *p;
  2090. if (lp3 < lp2) {
  2091. lp2--;
  2092. len++;
  2093. }
  2094. break;
  2095. } else
  2096. p++;
  2097. }
  2098. }
  2099. #endif /* KLUDGE */
  2100. lp = lp2;
  2101. while ((*s++ = *lp++)) /* Copy result to target buffer */
  2102. n--; /* accounting for length */
  2103. s--; /* Back up over the NUL */
  2104. /* Check whether this line is continued */
  2105. if (flag) /* No line continuation when flag=1 */
  2106. break; /* So break out of read-lines loop */
  2107. #ifdef COMMENT
  2108. debug(F000,"getnct first char","",*lp3);
  2109. debug(F000,"getnct last char","",ccl);
  2110. debug(F000,"getnct next-to-last char","",ccx);
  2111. #endif /* COMMENT */
  2112. if (bc > 0 && *lp3 == '}') { /* First char on line is '}' */
  2113. bc--; /* Decrement block counter */
  2114. }
  2115. if (bc == 0 && /* Line is continued if bc > 0 */
  2116. #ifdef COMMENT
  2117. /* Not supported as of C-Kermit 6.0 */
  2118. ccl != CMDQ && /* or line ends with CMDQ */
  2119. #endif /* COMMENT */
  2120. ccl != '-' && /* or line ends with dash */
  2121. ccl != '{') { /* or line ends with opening brace */
  2122. break; /* None of those, we're done. */
  2123. }
  2124. if (ccl == '-' || ccl == '{') /* Continuation character */
  2125. if (ccx == CMDQ) /* But it's quoted */
  2126. break; /* so ignore it */
  2127. if (ccl == '{') { /* Last char on line is '{'? */
  2128. bc++; /* Count the block opener. */
  2129. } else if (ccl == '-') { /* Explicit continue? */
  2130. char c, * ss;
  2131. int state = 0, nn;
  2132. s--; /* Yes, back up over terminators */
  2133. n++; /* and over continuation character */
  2134. nn = n; /* Save current count */
  2135. ss = s; /* and pointer */
  2136. s--; /* Back up over dash */
  2137. n++;
  2138. while (state < 2 && s >= prev) { /* Check for "{,-" */
  2139. n++;
  2140. c = *s--;
  2141. if (c <= SP)
  2142. continue;
  2143. if (c != ',' && c != '{')
  2144. break;
  2145. switch (state) {
  2146. case 0: /* Looking for comma */
  2147. if (c == ',')
  2148. state = 1;
  2149. break;
  2150. case 1: /* Looking for left brace */
  2151. if (c == '{') {
  2152. state = 2;
  2153. s += 2;
  2154. *s = NUL;
  2155. bc++;
  2156. }
  2157. break;
  2158. }
  2159. }
  2160. if (state != 2) { s = ss; n = nn; }
  2161. *s = NUL;
  2162. } else { /* None of those but (bc > 0) */
  2163. lastcomma = s;
  2164. *s++ = ','; /* and insert a comma */
  2165. n--;
  2166. }
  2167. #ifdef COMMENT
  2168. debug(F101,"getnct bc","",bc);
  2169. debug(F100,"getnct continued","",0);
  2170. #endif /* COMMENT */
  2171. *s = NUL;
  2172. prev = s;
  2173. } /* read-lines while loop */
  2174. if (lastcomma)
  2175. *lastcomma = SP;
  2176. if (!flag) /* Tack line terminator back on */
  2177. *s++ = c;
  2178. *s++ = NUL; /* Terminate the string */
  2179. untab(s2); /* Done, convert tabs to spaces */
  2180. #ifdef DEBUG
  2181. if (!flag) {
  2182. debug(F010,"CMD(F)",s2,0);
  2183. }
  2184. #endif /* DEBUG */
  2185. {
  2186. int i = 0; char *s = s2; char prev = '\0'; char c = '\0';
  2187. while (*s) { /* Save beginning of this command for error messages */
  2188. c = *s++;
  2189. if (c == '\n' || c == '\r') c = SP;
  2190. if (c == SP && prev == SP) /* Squeeze spaces */
  2191. continue;
  2192. lasttakeline[i++] = c;
  2193. prev = c;
  2194. if (i > TMPBUFSIZ-5) {
  2195. lasttakeline[i++] = '.';
  2196. lasttakeline[i++] = '.';
  2197. lasttakeline[i++] = '.';
  2198. lasttakeline[i++] = NUL;
  2199. break;
  2200. }
  2201. }
  2202. i = (int)strlen((char *)lasttakeline) - 1;
  2203. while (i > 0 && lasttakeline[i] == SP) { /* Trim treailing spaces */
  2204. lasttakeline[i] = NUL;
  2205. i--;
  2206. } }
  2207. free(lpx); /* Free temporary storage */
  2208. return(0); /* Return success */
  2209. }
  2210. VOID
  2211. shostack() { /* Dump the command stack */
  2212. int i;
  2213. char *p;
  2214. #ifndef NOSPL
  2215. for (i = cmdlvl; i > 0; i--) {
  2216. if (cmdstk[i].src == CMD_TF) {
  2217. p = tfnam[cmdstk[i].lvl];
  2218. if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2219. p = tmpbuf;
  2220. printf(" %2d. File : %s (line %d)\n",
  2221. i,
  2222. p,
  2223. tfline[cmdstk[i].lvl]
  2224. );
  2225. } else if (cmdstk[i].src == CMD_MD) {
  2226. char * m;
  2227. m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
  2228. if (i > 0) { /* Special handling for 2-level */
  2229. char *s; /* built-in macros... */
  2230. s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
  2231. if (s && cmdstk[i-1].src == CMD_MD) {
  2232. if (!strcmp(s,"_forx"))
  2233. m = "FOR";
  2234. else if (!strcmp(s,"_xif"))
  2235. m = "XIF";
  2236. else if (!strcmp(s,"_while"))
  2237. m = "WHILE";
  2238. else if (!strcmp(s,"_switx"))
  2239. m = "SWITCH";
  2240. }
  2241. }
  2242. printf(" %2d. Macro : %s\n",i,m);
  2243. } else if (cmdstk[i].src == CMD_KB) {
  2244. printf(" %2d. Prompt:\n",i);
  2245. } else {
  2246. printf(" %2d. ERROR : Command source unknown\n",i);
  2247. }
  2248. }
  2249. #else
  2250. for (i = tlevel; i > -1; i--) {
  2251. p = tfnam[i];
  2252. if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
  2253. p = tmpbuf;
  2254. printf(" %2d. File : %s (line %d)\n",
  2255. i,
  2256. p,
  2257. tfline[i]
  2258. );
  2259. }
  2260. #endif /* NOSPL */
  2261. if (i == 0)
  2262. printf(" %2d. Prompt: (top level)\n",0);
  2263. }
  2264. /* For command error messages - avoid dumping out the contents of some */
  2265. /* some huge FOR loop if it contains a syntax error. */
  2266. static char *
  2267. cmddisplay(s, cx) char * s; int cx; {
  2268. static char buf[80];
  2269. if ((int)strlen(s) > 70) {
  2270. sprintf(buf,"%.64s...",s); /* SAFE */
  2271. s = buf;
  2272. }
  2273. return(s);
  2274. }
  2275. static VOID
  2276. cmderr() {
  2277. if (xcmdsrc > 0) {
  2278. switch (cmd_err) { /* SET COMMAND ERROR-DISPLAY */
  2279. case 0:
  2280. break;
  2281. case 1:
  2282. case 2:
  2283. if (tlevel > -1) {
  2284. #ifndef NOSPL
  2285. if (xcmdsrc == 2)
  2286. printf(
  2287. "In macro or block defined in file: %s starting about line %d\n",
  2288. tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2289. );
  2290. else
  2291. #endif /* NOSPL */
  2292. printf("File: %s, Line: %d\n",
  2293. tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
  2294. );
  2295. }
  2296. #ifndef NOSPL
  2297. if (cmd_err == 2) {
  2298. if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2299. int m;
  2300. m = cmdstk[cmdlvl].lvl;
  2301. if (mlook(mactab,m_arg[m][0],nmac) >= 0)
  2302. printf("Macro name: %s\n", m_arg[m][0]);
  2303. }
  2304. }
  2305. #endif /* NOSPL */
  2306. break;
  2307. case 3:
  2308. printf("Command stack:\n");
  2309. shostack();
  2310. }
  2311. }
  2312. }
  2313. /* P A R S E R -- Top-level interactive command parser. */
  2314. /*
  2315. Call with:
  2316. m = 0 for normal behavior: keep parsing and executing commands
  2317. until an action command is parsed, then return with a
  2318. Kermit start-state as the value of this function.
  2319. m = 1 to parse only one command, can also be used to call parser()
  2320. recursively.
  2321. m = 2 to read but do not execute one command.
  2322. In all cases, parser() returns:
  2323. 0 if no Kermit protocol action required
  2324. > 0 with a Kermit protocol start-state.
  2325. < 0 upon error.
  2326. */
  2327. int
  2328. parser(m) int m; {
  2329. int tfcode, xx, yy, zz; /* Workers */
  2330. int is_tn = 0;
  2331. int cdlost = 0;
  2332. #ifndef NOSPL
  2333. int inlevel; /* Level we were called at */
  2334. extern int askflag, echostars;
  2335. #endif /* NOSPL */
  2336. char *cbp; /* Command buffer pointer */
  2337. #ifdef MAC
  2338. extern char *lfiles; /* Fake extern cast */
  2339. #endif /* MAC */
  2340. extern int interrupted;
  2341. #ifndef NOXFER
  2342. extern int sndcmd, getcmd, fatalio, clearrq;
  2343. #endif /* NOXFER */
  2344. #ifdef AMIGA
  2345. reqres(); /* Restore AmigaDOS requestors */
  2346. #endif /* AMIGA */
  2347. #ifdef OS2
  2348. if (cursor_save > -1) { /* Restore cursor if it was */
  2349. cursorena[VCMD] = cursor_save; /* turned off during file transfer */
  2350. cursor_save = -1;
  2351. }
  2352. #endif /* OS2 */
  2353. #ifdef IKSDB
  2354. if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
  2355. #endif /* IKSDB */
  2356. is_tn = (local && network && IS_TELNET()) ||
  2357. (!local && sstelnet);
  2358. if (!xcmdsrc) /* If at top (interactive) level ... */
  2359. concb((char)escape); /* put console in 'cbreak' mode. */
  2360. #ifdef CK_TMPDIR
  2361. /* If we were cd'd temporarily to another device or directory ... */
  2362. if (f_tmpdir) {
  2363. int x;
  2364. x = zchdir((char *) savdir); /* ... restore previous directory */
  2365. f_tmpdir = 0; /* and remember we did it. */
  2366. debug(F111,"parser tmpdir restoring",savdir,x);
  2367. }
  2368. #endif /* CK_TMPDIR */
  2369. #ifndef NOSPL
  2370. inlevel = cmdlvl; /* Current macro level */
  2371. #ifdef DEBUG
  2372. if (deblog) {
  2373. debug(F101,"&parser entry maclvl","",maclvl);
  2374. debug(F101,"&parser entry inlevel","",inlevel);
  2375. debug(F101,"&parser entry tlevel","",tlevel);
  2376. debug(F101,"&parser entry cmdlvl","",cmdlvl);
  2377. debug(F101,"&parser entry m","",m);
  2378. }
  2379. #endif /* DEBUG */
  2380. #endif /* NOSPL */
  2381. #ifndef NOXFER
  2382. ftreset(); /* Reset global file settings */
  2383. #endif /* NOXFER */
  2384. /*
  2385. sstate becomes nonzero when a command has been parsed that requires some
  2386. action from the protocol module. Any non-protocol actions, such as local
  2387. directory listing or terminal emulation, are invoked directly from below.
  2388. */
  2389. sstate = 0; /* Start with no start state. */
  2390. #ifndef NOXFER
  2391. #ifndef NOSPL
  2392. query = 0; /* QUERY not active */
  2393. #endif /* NOSPL */
  2394. #ifndef NOHINTS
  2395. if (!success) {
  2396. if (local && !network && carrier != CAR_OFF) {
  2397. int x; /* Serial connection */
  2398. x = ttgmdm(); /* with carrier checking */
  2399. if (x > -1) {
  2400. if (!(x & BM_DCD)) {
  2401. cdlost = 1;
  2402. fatalio = 1;
  2403. }
  2404. }
  2405. }
  2406. }
  2407. #ifdef DEBUG
  2408. if (deblog) {
  2409. debug(F101,"parser top what","",what);
  2410. debug(F101,"parser top interrupted","",interrupted);
  2411. debug(F101,"parser top cdlost","",cdlost);
  2412. debug(F101,"parser top sndcmd","",sndcmd);
  2413. debug(F101,"parser top getcmd","",getcmd);
  2414. }
  2415. #endif /* DEBUG */
  2416. if (cdlost && !interrupted && (sndcmd || getcmd)) {
  2417. printf("?Connection broken (carrier signal lost)\n");
  2418. }
  2419. if (sndcmd && protocol == PROTO_K &&
  2420. !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2421. int x = 0, n = 0;
  2422. printf("\n*************************\n");
  2423. printf("SEND-class command failed.\n");
  2424. printf(" Packets sent: %d\n", spackets);
  2425. printf(" Retransmissions: %d\n",retrans);
  2426. printf(" Timeouts: %d\n", timeouts);
  2427. printf(" Damaged packets: %d\n", crunched);
  2428. if (epktrcvd) {
  2429. printf(" Transfer canceled by receiver.\n");
  2430. printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
  2431. n++;
  2432. } else {
  2433. if (epktmsg) if (*epktmsg) {
  2434. printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
  2435. n++;
  2436. }
  2437. }
  2438. if (local && !network && carrier != CAR_OFF) {
  2439. int xx; /* Serial connection */
  2440. xx = ttgmdm(); /* with carrier checking */
  2441. if (xx > -1) {
  2442. if (!(xx & BM_DCD))
  2443. cdlost = 1;
  2444. }
  2445. }
  2446. #ifdef UNIX
  2447. if (errno != 0)
  2448. #endif /* UNIX */
  2449. {
  2450. printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
  2451. n++;
  2452. }
  2453. printf(
  2454. "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2455. (n > 1) ? "s do" : " does"
  2456. );
  2457. #ifndef NOLOCAL
  2458. if (local) {
  2459. if (rpackets == 0) {
  2460. printf(" . Did you start a Kermit receiver on the far end?\n");
  2461. } else {
  2462. printf(
  2463. " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
  2464. if (!network && mdmtyp > 0)
  2465. if ((3 * crunched) > spackets)
  2466. printf(
  2467. " . Try placing a new call to get a cleaner connection.\n");
  2468. }
  2469. } else if (rpackets > 0) {
  2470. if (flow == FLO_NONE)
  2471. printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2472. else
  2473. printf(" . Give me a SET FLOW NONE command and try again.\n");
  2474. }
  2475. x++;
  2476. #endif /* NOLOCAL */
  2477. if ((3 * timeouts) > spackets)
  2478. printf(" . Adjust the timeout method (see HELP SET SEND).\n");
  2479. if ((3 * retrans) > spackets)
  2480. printf(" . Increase the retry limit (see HELP SET RETRY).\n");
  2481. #ifdef CK_SPEED
  2482. if (prefixing != PX_ALL && rpackets > 2) {
  2483. printf(" . Try it again with: SET PREFIXING ALL\n");
  2484. x++;
  2485. }
  2486. #endif /* CK_SPEED */
  2487. #ifdef STREAMING
  2488. if (streamed) {
  2489. printf(" . Try it again with: SET STREAMING OFF\n");
  2490. x++;
  2491. } else if (reliable) {
  2492. printf(" . Try it again with: SET RELIABLE OFF\n");
  2493. x++;
  2494. }
  2495. #endif /* STREAMING */
  2496. #ifdef CK_SPEED
  2497. if (clearrq > 0 && prefixing == PX_NON) {
  2498. printf(" . Try it again with: SET CLEAR-CHANNEL OFF\n");
  2499. x++;
  2500. }
  2501. #endif /* CK_SPEED */
  2502. if (!parity) {
  2503. printf(" . Try it again with: SET PARITY SPACE\n");
  2504. x++;
  2505. }
  2506. printf(" . %sive a ROBUST command and try again.\n",
  2507. (x > 0) ? "As a last resort, g" : "G"
  2508. );
  2509. printf("Also:\n");
  2510. printf(" . Be sure the source file has read permission.\n");
  2511. printf(" . Be sure the target directory has write permission.\n");
  2512. /*
  2513. if the file was 2G or larger make sure other Kermit supports LFs...
  2514. */
  2515. printf(" . Be sure the target disk has sufficient space.\n");
  2516. printf("(Use SET HINTS OFF to suppress hints.)\n");
  2517. printf("*************************\n\n");
  2518. }
  2519. debug(F101,"topcmd","",topcmd);
  2520. if (getcmd && protocol == PROTO_K &&
  2521. !success && hints && !interrupted && !fatalio && !xcmdsrc) {
  2522. int x = 0;
  2523. extern int urpsiz, wslotr;
  2524. printf("\n*************************\n");
  2525. printf("RECEIVE- or GET-class command failed.\n");
  2526. printf(" Packets received: %d\n", rpackets);
  2527. printf(" Damaged packets: %d\n", crunched);
  2528. printf(" Timeouts: %d\n", timeouts);
  2529. if (rpackets > 0)
  2530. printf(" Packet length: %d\n", urpsiz);
  2531. if (epktrcvd) {
  2532. printf(" Transfer canceled by sender.\n");
  2533. printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
  2534. if (ckindex("not found",(char *)epktmsg,0,0,0) ||
  2535. ckindex("no such",(char *)epktmsg,0,0,0)) {
  2536. printf(" Did you spell the filename right?\n");
  2537. printf(" Is the other Kermit CD'd to the right directory?\n");
  2538. }
  2539. }
  2540. #ifdef UNIX
  2541. if (errno != 0)
  2542. #endif /* UNIX */
  2543. {
  2544. (VOID) ckstrncpy(tmpbuf,ck_errstr(),TMPBUFSIZ);
  2545. printf(" Most recent local error: \"%s\"\n",tmpbuf);
  2546. }
  2547. #ifdef COMMENT
  2548. printf(
  2549. "\nHINTS... If the preceding error message%s not explain the failure:\n",
  2550. epktrcvd ? "s do" : " does"
  2551. );
  2552. #ifndef NOLOCAL
  2553. if (local) {
  2554. if (topcmd == XXGET)
  2555. printf(" . Did you start a Kermit SERVER on the far end?\n");
  2556. if (rpackets == 0) {
  2557. if (topcmd != XXGET)
  2558. printf(" . Did you start a Kermit SENDer on the far end?\n");
  2559. } else {
  2560. printf(
  2561. " . Choose a different FLOW-CONTROL setting and try again.\n");
  2562. }
  2563. } else if (topcmd == XXGET)
  2564. printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
  2565. if (rpackets > 0 && urpsiz > 90)
  2566. printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
  2567. if (rpackets > 0 && wslotr > 1 && !streamed)
  2568. printf(" . Try a smaller window size (SET WINDOW).\n");
  2569. if (!local && rpackets > 0) {
  2570. if (flow == FLO_NONE)
  2571. printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
  2572. else
  2573. printf(" . Give me a SET FLOW NONE command and try again.\n");
  2574. }
  2575. x++;
  2576. #endif /* NOLOCAL */
  2577. #ifdef STREAMING
  2578. if (streamed) {
  2579. printf(" . Try it again with: SET STREAMING OFF\n");
  2580. x++;
  2581. } else if (reliable && local) {
  2582. printf(" . Try it again with: SET RELIABLE OFF\n");
  2583. x++;
  2584. } else
  2585. #endif /* STREAMING */
  2586. if (!parity) {
  2587. printf(" . Try it again with: SET PARITY SPACE\n");
  2588. x++;
  2589. }
  2590. printf((x > 0) ?
  2591. " . As a last resort, give a ROBUST command and try again.\n" :
  2592. " . Give a ROBUST command and try again.\n"
  2593. );
  2594. #endif /* COMMENT */
  2595. printf("Also:\n");
  2596. printf(" . Be sure the target directory has write permission.\n");
  2597. printf(" . Be sure the target disk has sufficient space.\n");
  2598. printf(" . Try telling the %s to SET PREFIXING ALL.\n",
  2599. topcmd == XXGET ? "server" : "sender"
  2600. );
  2601. printf(" . Try giving a ROBUST command to the %s.\n",
  2602. topcmd == XXGET ? "server" : "sender"
  2603. );
  2604. printf("(Use SET HINTS OFF to suppress hints.)\n");
  2605. printf("*************************\n\n");
  2606. }
  2607. #endif /* NOHINTS */
  2608. getcmd = 0;
  2609. sndcmd = 0;
  2610. interrupted = 0;
  2611. #endif /* NOXFER */
  2612. while (sstate == 0) { /* Parse cmds until action requested */
  2613. debug(F100,"parse top","",0);
  2614. what = W_COMMAND; /* Now we're parsing commands. */
  2615. rcdactive = 0; /* REMOTE CD not active */
  2616. keepallchars = 0; /* MINPUT not active */
  2617. #ifdef OS2
  2618. if (apcactive == APC_INACTIVE)
  2619. WaitCommandModeSem(-1);
  2620. #endif /* OS2 */
  2621. #ifdef IKS_OPTION
  2622. if ((local &&
  2623. !xcmdsrc &&
  2624. is_tn &&
  2625. TELOPT_ME(TELOPT_KERMIT) &&
  2626. TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
  2627. (!local &&
  2628. !cmdadl &&
  2629. TELOPT_ME(TELOPT_KERMIT) &&
  2630. TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
  2631. ) {
  2632. tn_siks(KERMIT_STOP);
  2633. }
  2634. #endif /* IKS_OPTION */
  2635. #ifndef NOXFER
  2636. if (autopath) {
  2637. fnrpath = PATH_AUTO;
  2638. autopath = 0;
  2639. }
  2640. remfile = 0; /* Clear these in case REMOTE */
  2641. remappd = 0; /* command was interrupted... */
  2642. rempipe = 0;
  2643. makestr(&snd_move,g_snd_move); /* Restore these */
  2644. makestr(&rcv_move,g_rcv_move);
  2645. makestr(&snd_rename,g_snd_rename);
  2646. makestr(&rcv_rename,g_rcv_rename);
  2647. #endif /* NOXFER */
  2648. /* Take requested action if there was an error in the previous command */
  2649. setint();
  2650. debug(F101,"parser tlevel","",tlevel);
  2651. debug(F101,"parser cmd_rows","",cmd_rows);
  2652. #ifndef NOLOCAL
  2653. debug(F101,"parser wasclosed","",wasclosed);
  2654. if (wasclosed) { /* If connection was just closed */
  2655. #ifndef NOSPL
  2656. int k;
  2657. k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
  2658. if (k >= 0) { /* If found, */
  2659. /* printf("ON_CLOSE CMD LOOP\n"); */
  2660. dodo(k,ckitoa(whyclosed),0); /* Set it up */
  2661. }
  2662. #endif /* NOSPL */
  2663. whyclosed = WC_REMO;
  2664. wasclosed = 0;
  2665. }
  2666. #endif /* NOLOCAL */
  2667. #ifndef NOSPL
  2668. xxdot = 0; /* Clear this... */
  2669. debug(F101,"parser success","",success);
  2670. if (success == 0) {
  2671. if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
  2672. printf("Command file terminated by error.\n");
  2673. popclvl();
  2674. if (cmdlvl == 0) return(0);
  2675. }
  2676. if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
  2677. printf("Command error: macro terminated.\n");
  2678. popclvl();
  2679. if (m && (cmdlvl < inlevel))
  2680. return((int) sstate);
  2681. }
  2682. }
  2683. nulcmd = (m == 2);
  2684. debug(F101,"parser nulcmd","",nulcmd);
  2685. #else
  2686. if (success == 0 && tlevel > -1 && takerr[tlevel]) {
  2687. printf("Command file terminated by error.\n");
  2688. popclvl();
  2689. cmini(ckxech); /* Clear the cmd buffer. */
  2690. if (tlevel < 0) /* Just popped out of cmd files? */
  2691. return(0); /* End of init file or whatever. */
  2692. }
  2693. #endif /* NOSPL */
  2694. #ifdef MAC
  2695. /* Check for TAKE initiated by menu. */
  2696. if ((tlevel == -1) && lfiles)
  2697. startlfile();
  2698. #endif /* MAC */
  2699. /* If in TAKE file, check for EOF */
  2700. #ifndef NOSPL
  2701. #ifdef MAC
  2702. if
  2703. #else
  2704. while
  2705. #endif /* MAC */
  2706. ((cmdstk[cmdlvl].src == CMD_TF) /* If end of take file */
  2707. && (tlevel > -1)
  2708. && feof(tfile[tlevel])) {
  2709. popclvl(); /* pop command level */
  2710. cmini(ckxech); /* and clear the cmd buffer. */
  2711. if (cmdlvl == 0) { /* Just popped out of all cmd files? */
  2712. return(0); /* End of init file or whatever. */
  2713. }
  2714. }
  2715. #ifdef MAC
  2716. miniparser(1);
  2717. if (sstate == 'a') { /* if cmd-. cancel */
  2718. debug(F100, "parser: cancel take due to sstate", "", sstate);
  2719. sstate = '\0';
  2720. dostop();
  2721. return(0); /* End of init file or whatever. */
  2722. }
  2723. #endif /* MAC */
  2724. #else /* NOSPL */
  2725. if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
  2726. popclvl(); /* Pop up one level. */
  2727. cmini(ckxech); /* and clear the cmd buffer. */
  2728. if (tlevel < 0) /* Just popped out of cmd files? */
  2729. return(0); /* End of init file or whatever. */
  2730. }
  2731. #endif /* NOSPL */
  2732. #ifndef NOSPL
  2733. debug(F101,"parser cmdlvl","",cmdlvl);
  2734. debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);
  2735. if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
  2736. debug(F100,"parser macro","",0);
  2737. maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
  2738. debug(F101,"parser maclvl","",maclvl);
  2739. cbp = cmdbuf; /* Copy next cmd to command buffer. */
  2740. *cbp = NUL;
  2741. if (*savbuf) { /* In case then-part of 'if' command */
  2742. ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
  2743. *savbuf = '\0';
  2744. } else { /* Else get next cmd from macro def */
  2745. if (getncm(cbp,CMDBL) < 0) {
  2746. #ifdef DEBUG
  2747. if (deblog) {
  2748. debug(F101,"parser end of macro m","",m);
  2749. debug(F101,"parser end of macro cmdlvl","",cmdlvl);
  2750. debug(F101,"parser end of macro inlevel","",inlevel);
  2751. }
  2752. #endif /* DEBUG */
  2753. if (m && (cmdlvl < inlevel))
  2754. return((int) sstate);
  2755. else /* if (!m) */ continue;
  2756. }
  2757. }
  2758. debug(F010,"CMD(M)",cmdbuf,0);
  2759. } else if (cmdstk[cmdlvl].src == CMD_TF)
  2760. #else
  2761. if (tlevel > -1)
  2762. #endif /* NOSPL */
  2763. {
  2764. #ifndef NOSPL
  2765. debug(F111,"parser savbuf",savbuf,tlevel);
  2766. if (*savbuf) { /* In case THEN-part of IF command */
  2767. ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
  2768. *savbuf = '\0';
  2769. } else
  2770. #endif /* NOSPL */
  2771. /* Get next line from TAKE file */
  2772. if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
  2773. debug(F111,"parser tfcode",tfile[tlevel],tfcode);
  2774. if (tfcode < -1) { /* Error */
  2775. printf("?Error in TAKE command file: %s\n",
  2776. (tfcode == -2) ? "Memory allocation failure" :
  2777. "Line too long or contains NUL characters"
  2778. );
  2779. dostop();
  2780. }
  2781. continue; /* -1 means EOF */
  2782. }
  2783. /* If interactive, get next command from user. */
  2784. } else { /* User types it in. */
  2785. if (pflag) prompt(xxstring);
  2786. cmini(ckxech);
  2787. }
  2788. /* Now we know where next command is coming from. Parse and execute it. */
  2789. repars = 1; /* 1 = command needs parsing */
  2790. #ifndef NOXFER
  2791. displa = 0; /* Assume no file transfer display */
  2792. #endif /* NOXFER */
  2793. while (repars) { /* Parse this cmd until entered. */
  2794. debug(F101,"parser top of while loop","",0);
  2795. xaskmore = saveask; /* Restore global more-prompting */
  2796. diractive = 0; /* DIR command not active */
  2797. cdactive = 0; /* CD command not active */
  2798. #ifndef NOSPL
  2799. askflag = 0; /* ASK command not active */
  2800. echostars = 0; /* Nor ASKQ */
  2801. debok = 1; /* Undisable debugging */
  2802. #endif /* NOSPL */
  2803. #ifdef RECURSIVE
  2804. /* In case of "send /recursive ./?<Ctrl-U>" etc */
  2805. recursive = 0; /* This is never sticky */
  2806. #endif /* RECURSIVE */
  2807. xfiletype = -1; /* Reset this between each command */
  2808. #ifndef NOMSEND
  2809. addlist = 0;
  2810. #endif /* NOMSEND */
  2811. #ifdef CK_RECALL
  2812. on_recall = 1;
  2813. #endif /* CK_RECALL */
  2814. /* This might have been changed by a switch */
  2815. if (g_matchdot > -1) {
  2816. matchdot = g_matchdot;
  2817. g_matchdot = -1;
  2818. }
  2819. cmres(); /* Reset buffer pointers. */
  2820. #ifdef OS2
  2821. #ifdef COMMENT
  2822. /* we check to see if a macro is waiting to be executed */
  2823. /* if so, we call domac on it */
  2824. if (cmdmac) {
  2825. ckstrncpy(cmdbuf, cmdmac, CMDBL);
  2826. free(cmdmac);
  2827. cmdmac = NULL;
  2828. }
  2829. #endif /* COMMENT */
  2830. #endif /* OS2 */
  2831. #ifndef NOXFER
  2832. bye_active = 0;
  2833. #endif /* NOXFER */
  2834. havetoken = 0;
  2835. xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
  2836. debug(F101,"top-level cmkey2","",xx);
  2837. if (xx == -5) {
  2838. yy = chktok(toktab);
  2839. debug(F101,"top-level cmkey token","",yy);
  2840. #ifndef COMMENT
  2841. /* Either way makes absolutely no difference */
  2842. debug(F110,"NO UNGWORD",atmbuf,0);
  2843. /* ungword(); */
  2844. #else
  2845. debug(F110,"TOKEN UNGWORD",atmbuf,0);
  2846. ungword();
  2847. #endif /* COMMENT */
  2848. switch (yy) {
  2849. case '#': xx = XXCOM; break; /* Comment */
  2850. case ';': xx = XXCOM; break; /* Comment */
  2851. #ifndef NOSPL
  2852. case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
  2853. case ':': xx = XXLBL; break; /* GOTO label */
  2854. #endif /* NOSPL */
  2855. #ifndef NOPUSH
  2856. #ifdef CK_REDIR
  2857. case '<':
  2858. #endif /* CK_REDIR */
  2859. case '@':
  2860. case '!':
  2861. if (nopush) {
  2862. char *s; int x;
  2863. if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
  2864. return(x);
  2865. success = 0;
  2866. xx = XXCOM;
  2867. } else {
  2868. switch(yy) {
  2869. #ifdef CK_REDIR
  2870. case '<': xx = XXFUN; break; /* REDIRECT */
  2871. #endif /* CK_REDIR */
  2872. case '@':
  2873. case '!': xx = XXSHE; break; /* Shell escape */
  2874. }
  2875. }
  2876. break;
  2877. #endif /* NOPUSH */
  2878. #ifdef CK_RECALL
  2879. case '^': xx = XXREDO; break;
  2880. #endif /* CK_RECALL */
  2881. #ifndef NOSPL
  2882. case '{': xx = XXMACRO; break;
  2883. case '(': xx = XXSEXP; break;
  2884. #endif /* NOSPL */
  2885. default:
  2886. if (!quiet && !cmd_err) {
  2887. printf("\n?Not a valid command or token - \"%s\"\n",
  2888. cmddisplay((char *)cmdbuf,xx)
  2889. );
  2890. /* cmderr(); */ newerrmsg("");
  2891. }
  2892. xx = -2;
  2893. }
  2894. havetoken = 1;
  2895. debug(F101,"HAVE TOKEN","",xx);
  2896. }
  2897. if (xx > -1) {
  2898. topcmd = xx; /* Top-level command index */
  2899. #ifndef NOSPL
  2900. if (maclvl > -1)
  2901. lastcmd[maclvl] = xx;
  2902. #endif /* NOSPL */
  2903. debug(F101,"topcmd","",topcmd);
  2904. debug(F101,"cmflgs","",cmflgs);
  2905. }
  2906. #ifndef NOSPL
  2907. /* Special handling for IF..ELSE */
  2908. debug(F101,"cmdlvl","",cmdlvl);
  2909. debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);
  2910. if (ifcmd[cmdlvl]) /* Count stmts after IF */
  2911. ifcmd[cmdlvl]++;
  2912. if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
  2913. ifcmd[cmdlvl] = 0;
  2914. /* Execute the command and take action based on return code. */
  2915. if (nulcmd) { /* Ignoring this command? */
  2916. xx = XXCOM; /* Make this command a comment. */
  2917. }
  2918. fnsuccess = 1; /* For catching \function() errors */
  2919. #endif /* NOSPL */
  2920. debug(F101,"calling docmd()","",xx);
  2921. zz = docmd(xx); /* Parse rest of command & execute. */
  2922. #ifndef NOSPL
  2923. { /* For \v(lastcommand) */
  2924. extern char * prevcmd;
  2925. /* The exception list kind of a hack but let's try it... */
  2926. if (ckstrcmp(cmdbuf,"_getarg",7,0) &&
  2927. ckstrcmp(cmdbuf,"if ",3,0) &&
  2928. ckstrcmp(cmdbuf,"xif ",4,0) &&
  2929. ckstrcmp(cmdbuf,"do _if",6,0) &&
  2930. ckstrcmp(cmdbuf,"_assign _if",11,0))
  2931. ckstrncpy(prevcmd,cmdbuf,CMDBL);
  2932. }
  2933. #endif /* NOSPL */
  2934. #ifndef NOSPL
  2935. if (fnerror && !fnsuccess)
  2936. success = 0;
  2937. #endif /* NOSPL */
  2938. debug(F101,"docmd returns","",zz);
  2939. /* debug(F011,"cmdbuf",cmdbuf,30); */
  2940. /* debug(F011,"atmbuf",atmbuf,30); */
  2941. #ifdef MAC
  2942. if (tlevel > -1) {
  2943. if (sstate == 'a') { /* if cmd-. cancel */
  2944. debug(F110, "parser: cancel take, sstate:", "a", 0);
  2945. sstate = '\0';
  2946. dostop();
  2947. return(0); /* End of init file or whatever. */
  2948. }
  2949. }
  2950. #endif /* MAC */
  2951. switch (zz) {
  2952. case -4: /* EOF (e.g. on redirected stdin) */
  2953. doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
  2954. case -1: /* Reparse needed */
  2955. repars = 1; /* Just set reparse flag and... */
  2956. continue;
  2957. #ifdef OS2
  2958. case -7: /* They typed a disk letter */
  2959. if (!zchdir((char *)cmdbuf)) {
  2960. perror((char *)cmdbuf);
  2961. success = 0;
  2962. } else success = 1;
  2963. repars = 0;
  2964. continue;
  2965. #endif /* OS2 */
  2966. /*
  2967. Changed 2013-12-06 fdc: Previously the failing command was echoed only in
  2968. the -6 and -9 cases. This made it difficult to know exactly which command
  2969. had failed when a macro or command file was being executed and the failing
  2970. command had already issued its own error message and returned -9. Now we
  2971. include -9 in the caselist for this code, but we echo the failing command
  2972. only if Kermit is not at top level. So now, even though the error message
  2973. is imprecise about *where* the failing command was, at least it shows the
  2974. failing command.
  2975. */
  2976. case -9: /* Bad, error message already done */
  2977. case -6: /* Invalid command given w/no args */
  2978. case -2: /* Invalid command given w/args */
  2979. if (zz == -2 || zz == -6 || (zz == -9 && cmdlvl > 0)) {
  2980. int x = 0;
  2981. char * eol = "";
  2982. x = strlen(cmdbuf); /* Avoid blank line */
  2983. #ifdef COMMENT
  2984. if (x > 0) {
  2985. if (cmdbuf[x-1] != LF)
  2986. eol = "\n";
  2987. printf("?Invalid: %s%s",
  2988. cmddisplay(cmdbuf,xx),eol
  2989. );
  2990. } else
  2991. printf("?Invalid\n");
  2992. #else
  2993. if (x > 0)
  2994. newerrmsg("Syntax error");
  2995. #endif /* COMMENT */
  2996. }
  2997. success = 0;
  2998. debug(F110,"top-level cmkey failed",cmdbuf,0);
  2999. /* If in background w/ commands coming stdin, terminate */
  3000. if (pflag == 0 && tlevel < 0)
  3001. fatal("Kermit command error in background execution");
  3002. /*
  3003. Command retry feature, edit 190. If we're at interactive prompting level,
  3004. reprompt the user with as much of the command as didn't fail.
  3005. */
  3006. #ifdef CK_RECALL
  3007. if (cm_retry && !xcmdsrc) { /* If at top level */
  3008. int len;
  3009. char *p, *s;
  3010. len = strlen(cmdbuf); /* Length of command buffer */
  3011. p = malloc(len + 1); /* Allocate space for copy */
  3012. if (p) { /* If we got the space copy */
  3013. strcpy(p,cmdbuf); /* the command buffer (SAFE). */
  3014. /* Chop off final field, the one that failed. */
  3015. s = p + len - 1; /* Point to end */
  3016. while (*s == SP && s > p) /* Trim blanks */
  3017. s--;
  3018. while (*s != SP && s > p) /* Trim last field */
  3019. s--;
  3020. if (s > p) /* Keep the space */
  3021. s++; /* after last good field */
  3022. if (s >= p) /* Cut off remainder */
  3023. *s = NUL;
  3024. cmini(ckxech); /* Reinitialize the parser */
  3025. ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
  3026. free(p); /* Free temporary storage */
  3027. p = NULL;
  3028. prompt(xxstring); /* Reprint the prompt */
  3029. printf("%s",cmdbuf); /* Reprint partial command */
  3030. repars = 1; /* Force reparse */
  3031. continue;
  3032. }
  3033. } else
  3034. #endif /* CK_RECALL */
  3035. /* cmderr(); */ newerrmsg("");
  3036. cmini(ckxech); /* (fall thru) */
  3037. case -3: /* Empty command OK at top level */
  3038. repars = 0; /* Don't need to reparse. */
  3039. continue; /* Go back and get another command. */
  3040. default: /* Command was successful. */
  3041. #ifndef NOSPL
  3042. debug(F101,"parser preparing to continue","",maclvl);
  3043. #endif /* NOSPL */
  3044. debug(F101,"parser success","",success);
  3045. repars = 0; /* Don't need to reparse. */
  3046. continue; /* Go back and get another command. */
  3047. }
  3048. }
  3049. #ifndef NOSPL
  3050. debug(F101,"parser breaks out of while loop","",maclvl);
  3051. if (m && (cmdlvl < inlevel)) return((int) sstate);
  3052. #endif /* NOSPL */
  3053. }
  3054. /* Got an action command, return start state. */
  3055. return((int) sstate);
  3056. }
  3057. #ifndef NOSPL
  3058. /*
  3059. OUTPUT command.
  3060. Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
  3061. */
  3062. #define OBSIZE 80 /* Size of local character buffer */
  3063. static int obn; /* Buffer offset (high water mark) */
  3064. static char obuf[OBSIZE+1]; /* OUTPUT buffer. */
  3065. static char *obp; /* Pointer to output buffer. */
  3066. _PROTOTYP( static int oboc, (char) );
  3067. _PROTOTYP( static int xxout, (char *, int) );
  3068. static int
  3069. #ifdef CK_ANSIC
  3070. xxout(char *obuf, int obsize)
  3071. #else
  3072. xxout(obuf, obsize) char *obuf; int obsize;
  3073. #endif /* CK_ANSIC */
  3074. /* xxout */ { /* OUTPUT command's output function */
  3075. int i, rc;
  3076. debug(F101,"xxout obsize","",obsize);
  3077. debug(F101,"xxout pacing","",pacing);
  3078. debug(F111,"xxout string",obuf,strlen(obuf));
  3079. rc = 0; /* Initial return code. */
  3080. if (!obuf || (obsize <= 0)) /* Nothing to output. */
  3081. goto xxout_x; /* Return successfully */
  3082. rc = -1; /* Now assume failure */
  3083. if (pacing == 0) { /* Is pacing enabled? */
  3084. if ((local ? /* No, write entire string at once */
  3085. ttol((CHAR *)obuf, obsize) : /* to communications device */
  3086. conxo(obsize, obuf)) /* or to console */
  3087. != obsize)
  3088. goto xxout_x;
  3089. } else {
  3090. for (i = 0; i < obsize; i++) { /* Write individual chars */
  3091. if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
  3092. goto xxout_x;
  3093. msleep(pacing);
  3094. }
  3095. }
  3096. if (duplex) {
  3097. #ifdef OS2
  3098. if (inecho && local) {
  3099. #ifndef NOLOCAL
  3100. for (i = 0; i < obsize; i++) { /* Write to emulator */
  3101. scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
  3102. }
  3103. #endif /* NOLOCAL */
  3104. conxo(obsize,obuf);
  3105. } else if (seslog) { /* or log session here */
  3106. logstr((char *) obuf, obsize);
  3107. }
  3108. #else /* OS2 */
  3109. if (seslog) {
  3110. logstr((char *) obuf, obsize);
  3111. }
  3112. if (inecho && local) {
  3113. conxo(obsize,obuf);
  3114. }
  3115. #endif /* OS2 */
  3116. }
  3117. rc = 0; /* Success */
  3118. xxout_x:
  3119. obn = 0; /* Reset count */
  3120. obp = obuf; /* and pointers */
  3121. return(rc); /* return our return code */
  3122. }
  3123. #ifdef COMMENT
  3124. /*
  3125. Macros for OUTPUT command execution, to make it go faster.
  3126. */
  3127. #define obfls() ((xxout(obuf,obn)<0)?-1:0)
  3128. #define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))
  3129. #else /* The macros cause some compilers to generate bad code. */
  3130. static int
  3131. #ifdef CK_ANSIC
  3132. oboc(char c)
  3133. #else
  3134. oboc(c) char c;
  3135. #endif /* CK_ANSIC */
  3136. /* oboc */ { /* OUTPUT command's output function */
  3137. *obp++ = c; /* Deposit character */
  3138. *obp = NUL; /* Flush buffer if it's now full */
  3139. return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
  3140. }
  3141. #endif /* COMMENT */
  3142. /* Routines for handling local variables -- also see popclvl(). */
  3143. VOID
  3144. freelocal(m) int m; { /* Free local variables */
  3145. struct localvar * v, * tv; /* at macro level m... */
  3146. debug(F101,"freelocal level","",m);
  3147. if (m < 0) return;
  3148. v = localhead[m]; /* List head for level m */
  3149. while (v) {
  3150. if (v->lv_name) /* Variable name */
  3151. free(v->lv_name);
  3152. if (v->lv_value) /* Value */
  3153. free(v->lv_value);
  3154. tv = v; /* Save pointer to this node */
  3155. v = v->lv_next; /* Get next one */
  3156. if (tv) /* Free this one */
  3157. free((char *)tv);
  3158. }
  3159. localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
  3160. }
  3161. #define MAXLOCALVAR 64
  3162. /* Return a pointer to the definition of a user-defined variable */
  3163. static char *
  3164. vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
  3165. char * p;
  3166. char c;
  3167. *isarray = 0;
  3168. if (!s) return(NULL);
  3169. if (!*s) return(NULL);
  3170. p = s;
  3171. if (*s == CMDQ) {
  3172. p++;
  3173. if (!*p)
  3174. return(NULL);
  3175. if ((c = *p) == '%') { /* Scalar variable. */
  3176. c = *++p; /* Get ID character. */
  3177. p = ""; /* Assume definition is empty */
  3178. if (!c)
  3179. return(NULL);
  3180. if (c >= '0' && c <= '9') { /* Digit for macro arg */
  3181. if (maclvl < 0) /* Digit variables are global */
  3182. return(g_var[c]); /* if no macro is active */
  3183. else /* otherwise */
  3184. return(m_arg[maclvl][c - '0']); /* they're on the stack */
  3185. } else if (isalpha(c)) {
  3186. if (isupper(c)) c -= ('a'-'A');
  3187. return(g_var[c]); /* Letter for global variable */
  3188. } else
  3189. return(NULL);
  3190. } else if (c == '&') { /* Array reference. */
  3191. int x, vbi, d;
  3192. x = arraynam(p,&vbi,&d); /* Get name and subscript */
  3193. if (x > -1 || d == -17) {
  3194. *isarray = 1;
  3195. *x1 = vbi;
  3196. *x2 = (d == -17) ? 0 : d;
  3197. }
  3198. if (x < 0)
  3199. return(NULL);
  3200. if (chkarray(vbi,d) >= 0) { /* Array is declared? */
  3201. vbi -= ARRAYBASE; /* Convert name to index */
  3202. if (a_dim[vbi] >= d) { /* If subscript in range */
  3203. char **ap;
  3204. ap = a_ptr[vbi];
  3205. return((ap) ? ap[d] : NULL);
  3206. }
  3207. }
  3208. }
  3209. return(NULL);
  3210. } else {
  3211. int k;
  3212. k = mxlook(mactab,s,nmac);
  3213. return((k > -1) ? mactab[k].mval : NULL);
  3214. }
  3215. }
  3216. int
  3217. addlocal(p) char * p; {
  3218. int x, z, isarray = 0;
  3219. char * s;
  3220. struct localvar * v, *prev = (struct localvar *)NULL;
  3221. extern int tra_asg; int tra_tmp;
  3222. tra_tmp = tra_asg;
  3223. s = vardef(p,&isarray,&x,&z); /* Get definition of variable */
  3224. if (isarray) { /* Arrays are handled specially */
  3225. pusharray(x,z);
  3226. return(0);
  3227. }
  3228. if (!s) s = "";
  3229. if ((v = localhead[cmdlvl])) { /* Already have some at this level? */
  3230. while (v) { /* Find end of list */
  3231. prev = v;
  3232. v = v->lv_next;
  3233. }
  3234. }
  3235. v = (struct localvar *) malloc(sizeof(struct localvar));
  3236. if (!v) {
  3237. printf("?Failure to allocate storage for local variables");
  3238. return(-9);
  3239. }
  3240. if (!localhead[cmdlvl]) /* If first, set list head */
  3241. localhead[cmdlvl] = v;
  3242. else /* Otherwise link previous to this */
  3243. prev->lv_next = v;
  3244. prev = v; /* And make this previous */
  3245. v->lv_next = (struct localvar *) NULL; /* No next yet */
  3246. if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
  3247. return(-1);
  3248. strcpy(v->lv_name, p); /* Copy name into new node (SAFE) */
  3249. if (*s) {
  3250. if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
  3251. return(-1);
  3252. strcpy(v->lv_value, s); /* Copy value into new node (SAFE) */
  3253. } else
  3254. v->lv_value = NULL;
  3255. tra_asg = 0;
  3256. delmac(p,1); /* Delete the original macro */
  3257. tra_asg = tra_tmp;
  3258. return(0);
  3259. }
  3260. int
  3261. dolocal() { /* Do the LOCAL command */
  3262. int i, x;
  3263. char * s;
  3264. char * list[MAXLOCALVAR+2]; /* Up to 64 variables per line */
  3265. if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
  3266. return(x);
  3267. xwords(s,MAXLOCALVAR,list,0); /* Break up line into "words" */
  3268. /* Note: Arrays do not use the localhead list, but have their own stack */
  3269. for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
  3270. if (addlocal(list[i]) < 0)
  3271. goto localbad;
  3272. }
  3273. return(success = 1);
  3274. localbad:
  3275. printf("?Failure to allocate storage for local variables");
  3276. freelocal(cmdlvl);
  3277. return(-9);
  3278. }
  3279. /* D O O U T P U T -- Returns 0 on failure, 1 on success */
  3280. #ifndef NOKVERBS
  3281. #define K_BUFLEN 30
  3282. #define SEND_BUFLEN 255
  3283. #define sendbufd(x) { osendbuf[sendndx++] = x;\
  3284. if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
  3285. #endif /* NOKVERBS */
  3286. int outesc = 1; /* Process special OUTPUT escapes */
  3287. int
  3288. dooutput(s, cx) char *s; int cx; {
  3289. #ifdef SSHBUILTIN
  3290. extern int ssh_cas;
  3291. extern char * ssh_cmd;
  3292. #endif /* SSHBUILTIN */
  3293. int x, xx, y, quote; /* Workers */
  3294. int is_tn = 0;
  3295. is_tn = (local && network && IS_TELNET()) ||
  3296. (!local && sstelnet);
  3297. debug(F111,"dooutput s",s,(int)strlen(s));
  3298. if (local) { /* Condition external line */
  3299. #ifdef NOLOCAL
  3300. goto outerr;
  3301. #else
  3302. if (ttchk() < 0) {
  3303. if (!network) {
  3304. if (carrier != CAR_OFF) {
  3305. int x;
  3306. x = ttgmdm();
  3307. if ((x > -1) && ((x & BM_DCD) == 0)) {
  3308. printf(
  3309. "?Carrier signal required but not present - Try SET CARRIER-WATCH OFF.\n"
  3310. );
  3311. return(0);
  3312. }
  3313. } else {
  3314. printf(
  3315. "?Problem with serial port or modem or cable - Try SHOW COMMUNICATIONS.\n"
  3316. );
  3317. return(0);
  3318. }
  3319. }
  3320. printf("?Connection %s %s is not open or not functioning.\n",
  3321. network ? "to" : "on",
  3322. ttname
  3323. );
  3324. return(0);
  3325. }
  3326. if (ttvt(speed,flow) < 0) {
  3327. printf("?OUTPUT initialization error\n");
  3328. return(0);
  3329. }
  3330. #endif /* NOLOCAL */
  3331. }
  3332. #ifdef SSHBUILTIN
  3333. if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd &&
  3334. !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
  3335. if (!quiet)
  3336. printf("?SSH Subsystem active: %s\n", ssh_cmd);
  3337. return(0);
  3338. }
  3339. #endif /* SSHBUILTIN */
  3340. if (!cmdgquo()) { /* COMMAND QUOTING OFF */
  3341. x = strlen(s); /* Just send the string literally */
  3342. xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
  3343. return(success = (xx == x) ? 1 : 0);
  3344. }
  3345. quote = 0; /* Initialize backslash (\) quote */
  3346. obn = 0; /* Reset count */
  3347. obp = obuf; /* and pointers */
  3348. outagain:
  3349. while ((x = *s++)) { /* Loop through the string */
  3350. y = 0; /* Error code, 0 = no error. */
  3351. debug(F000,"dooutput","",x);
  3352. if (quote) { /* This character is quoted */
  3353. #ifndef NOKVERBS
  3354. if (x == 'k' || x == 'K') { /* \k or \K */
  3355. extern struct keytab kverbs[];
  3356. extern int nkverbs;
  3357. extern char * keydefptr;
  3358. extern int keymac;
  3359. extern int keymacx;
  3360. int x, y, brace = 0;
  3361. int pause;
  3362. char * p, * b;
  3363. char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
  3364. char osendbuf[SEND_BUFLEN +1];
  3365. int sendndx = 0;
  3366. if (xxout(obuf,obn) < 0) /* Flush buffer */
  3367. goto outerr;
  3368. debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
  3369. { /* Have K verb? */
  3370. if (!*s) {
  3371. break;
  3372. }
  3373. /*
  3374. We assume that the verb name is {braced}, or it extends to the end of the
  3375. string, s, or it ends with a space, control character, or backslash.
  3376. */
  3377. p = kbuf; /* Copy verb name into local buffer */
  3378. x = 0;
  3379. while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
  3380. if (brace && *s == '}') {
  3381. break;
  3382. }
  3383. *p++ = *s++;
  3384. }
  3385. if (*s && !brace) /* If we broke because of \, etc, */
  3386. s--; /* back up so we get another look. */
  3387. brace = 0;
  3388. *p = NUL; /* Terminate. */
  3389. p = kbuf; /* Point back to beginning */
  3390. debug(F110,"dooutput kverb",p,0);
  3391. y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
  3392. debug(F101,"dooutput lookup",0,y);
  3393. if (y > -1) {
  3394. if (sendndx) {
  3395. dooutput(osendbuf,cx);
  3396. sendndx = 0;
  3397. }
  3398. dokverb(VCMD,y);
  3399. #ifndef NOSPL
  3400. } else { /* Is it a macro? */
  3401. y = mxlook(mactab,p,nmac);
  3402. if (y > -1) {
  3403. cmpush();
  3404. keymac = 1; /* Flag for key macro active */
  3405. keymacx = y; /* Key macro index */
  3406. keydefptr = s; /* Where to resume next time */
  3407. debug(F111,"dooutput mxlook",keydefptr,y);
  3408. parser(1);
  3409. cmpop();
  3410. }
  3411. #endif /* NOSPL */
  3412. }
  3413. }
  3414. quote = 0;
  3415. continue;
  3416. } else
  3417. #endif /* NOKVERBS */
  3418. if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
  3419. if (xxout(obuf,obn) < 0) /* Flush buffer */
  3420. goto outerr;
  3421. debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
  3422. if (local)
  3423. ttoc(NUL);
  3424. else
  3425. conoc(NUL);
  3426. quote = 0;
  3427. continue;
  3428. } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */
  3429. if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3430. goto outerr;
  3431. debug(F100,"OUTPUT BREAK","",0);
  3432. #ifndef NOLOCAL
  3433. ttsndb(); /* Send BREAK signal */
  3434. #else
  3435. if (local)
  3436. ttoc(NUL);
  3437. else
  3438. conoc(NUL);
  3439. #endif /* NOLOCAL */
  3440. quote = 0; /* Turn off quote flag */
  3441. continue; /* and not the b or B */
  3442. #ifdef CK_LBRK
  3443. } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
  3444. if (xxout(obuf,obn) < 0) /* Flush buffer first */
  3445. goto outerr;
  3446. debug(F100,"OUTPUT Long BREAK","",0);
  3447. #ifndef NOLOCAL
  3448. ttsndlb(); /* Send Long BREAK signal */
  3449. #else
  3450. if (local)
  3451. ttoc(NUL);
  3452. else
  3453. conoc(NUL);
  3454. #endif /* NOLOCAL */
  3455. quote = 0; /* Turn off quote flag */
  3456. continue; /* and not the l or L */
  3457. #endif /* CK_LBRK */
  3458. } else if (x == CMDQ) { /* Backslash itself */
  3459. debug(F100,"OUTPUT CMDQ","",0);
  3460. xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3461. if (xx < 0)
  3462. goto outerr;
  3463. quote = 0;
  3464. continue;
  3465. } else { /* if \ not followed by special esc */
  3466. /* Note: Atari ST compiler won't allow macro call in "if ()" */
  3467. xx = oboc(dopar(CMDQ)); /* Output the backslash. */
  3468. if (xx < 0)
  3469. goto outerr;
  3470. quote = 0; /* Turn off quote flag */
  3471. }
  3472. } else if (x == CMDQ) { /* This is the quote character */
  3473. quote = 1; /* Go back and get next character */
  3474. continue; /* which is quoted */
  3475. }
  3476. xx = oboc(dopar((char)x)); /* Output this character */
  3477. debug(F111,"dooutput",obuf,obn);
  3478. if (xx < 0)
  3479. goto outerr;
  3480. #ifdef COMMENT
  3481. if (seslog && duplex) { /* Log the character if log is on */
  3482. logchar((char)x);
  3483. }
  3484. #endif /* COMMENT */
  3485. if (x == '\015') { /* String contains carriage return */
  3486. int stuff = -1, stuff2 = -1;
  3487. if (tnlm) { /* TERMINAL NEWLINE ON */
  3488. stuff = LF; /* Stuff LF */
  3489. }
  3490. #ifdef TNCODE
  3491. /* TELNET NEWLINE ON/OFF/RAW */
  3492. if (is_tn) {
  3493. switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
  3494. tn_b_nlm :
  3495. tn_nlm
  3496. ) {
  3497. case TNL_CR:
  3498. break;
  3499. case TNL_CRNUL:
  3500. stuff2 = stuff;
  3501. stuff = NUL;
  3502. break;
  3503. case TNL_CRLF:
  3504. stuff2 = stuff;
  3505. stuff = LF;
  3506. break;
  3507. }
  3508. }
  3509. #endif /* TNCODE */
  3510. if (stuff > -1) { /* Stuffing another character... */
  3511. xx = oboc(dopar((CHAR)stuff));
  3512. if (xx < 0)
  3513. goto outerr;
  3514. #ifdef COMMENT
  3515. if (seslog && duplex) { /* Log stuffed char if appropriate */
  3516. logchar((char)stuff);
  3517. }
  3518. #endif /* COMMENT */
  3519. }
  3520. if (stuff2 > -1) { /* Stuffing another character... */
  3521. xx = oboc(dopar((CHAR)stuff2));
  3522. if (xx < 0)
  3523. goto outerr;
  3524. #ifdef COMMENT
  3525. if (seslog && duplex) { /* Log stuffed char if appropriate */
  3526. logchar((char)stuff2);
  3527. }
  3528. #endif /* COMMENT */
  3529. }
  3530. if (xxout(obuf,obn) < 0) /* Flushing is required here! */
  3531. goto outerr;
  3532. }
  3533. }
  3534. if (cx == XXLNOUT) {
  3535. s = "\015";
  3536. cx = 0;
  3537. goto outagain;
  3538. }
  3539. if (quote == 1) /* String ended with backslash */
  3540. xx = oboc(dopar(CMDQ));
  3541. if (obn > 0) /* OUTPUT done */
  3542. if (xxout(obuf,obn) < 0) /* Flush the buffer if necessary. */
  3543. goto outerr;
  3544. return(1);
  3545. outerr: /* OUTPUT command error handler */
  3546. if (msgflg) printf("?OUTPUT execution error\n");
  3547. return(0);
  3548. /* Remove "local" OUTPUT macro defininitions */
  3549. #ifdef COMMENT
  3550. /* No more macros ... */
  3551. #undef oboc
  3552. #undef obfls
  3553. #endif /* COMMENT */
  3554. }
  3555. #endif /* NOSPL */
  3556. /* Display version herald and initial prompt */
  3557. VOID
  3558. herald() {
  3559. int x = 0, i;
  3560. extern int srvcdmsg;
  3561. extern char * cdmsgfile[];
  3562. char * ssl;
  3563. char * krb4;
  3564. char * krb5;
  3565. #ifndef NOCMDL
  3566. extern char * bannerfile;
  3567. debug(F110,"herald bannerfile",bannerfile,0);
  3568. if (bannerfile) {
  3569. concb((char)escape);
  3570. if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
  3571. debug(F111,"herald","srvcdmsg",srvcdmsg);
  3572. if (srvcdmsg) {
  3573. for (i = 0; i < 8; i++) {
  3574. debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3575. if (zchki(cdmsgfile[i]) > -1) {
  3576. printf("\n");
  3577. dotype(cdmsgfile[i],
  3578. xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3579. break;
  3580. }
  3581. }
  3582. }
  3583. return;
  3584. }
  3585. }
  3586. #endif /* NOCMDL */
  3587. #ifdef COMMENT
  3588. /* The following generates bad code in SCO compilers. */
  3589. /* Observed in both OSR5 and Unixware 2 -- after executing this */
  3590. /* statement when all conditions are false, x has a value of -32. */
  3591. if (noherald || quiet || bgset > 0 || (bgset != 0 && backgrd != 0))
  3592. x = 1;
  3593. #else
  3594. x = 0;
  3595. if (noherald || quiet)
  3596. x = 1;
  3597. else if (bgset > 0)
  3598. x = 1;
  3599. else if (bgset < 0 && backgrd > 0)
  3600. x = 1;
  3601. #endif /* COMMENT */
  3602. ssl = "";
  3603. krb4 = "";
  3604. krb5 = "";
  3605. #ifdef CK_AUTHENTICATION
  3606. #ifdef CK_SSL
  3607. ssl = "+SSL";
  3608. #endif /* CK_SSL */
  3609. #ifdef KRB4
  3610. krb4 = "+KRB4";
  3611. #endif /* KRB4 */
  3612. #ifdef KRB5
  3613. krb5 = "+KRB5";
  3614. #endif /* KRB5 */
  3615. #endif /* CK_AUTHENTICATION */
  3616. if (x == 0) {
  3617. #ifdef datageneral
  3618. printf("%s, for%s\n",versio,ckxsys);
  3619. #else
  3620. #ifdef OSK
  3621. printf("%s, for%s\n",versio,ckxsys);
  3622. #else
  3623. #ifdef CK_64BIT
  3624. printf("%s, for%s%s%s%s (64-bit)\n\r",versio,ckxsys,ssl,krb4,krb5);
  3625. #else
  3626. printf("%s, for%s%s%s%s\n\r",versio,ckxsys,ssl,krb4,krb5);
  3627. #endif/* CK_64BIT */
  3628. #endif /* OSK */
  3629. #endif /* datageneral */
  3630. printf(" Copyright (C) 1985, %s,\n", ck_cryear);
  3631. printf(" Trustees of Columbia University in the City of New York.\n");
  3632. #ifdef COMMENT
  3633. #ifdef OS2
  3634. shoreg();
  3635. #endif /* OS2 */
  3636. #endif /* COMMENT */
  3637. if (!quiet && !backgrd) {
  3638. #ifdef COMMENT
  3639. /* "Default file-transfer mode is AUTOMATIC" is useless information... */
  3640. char * s;
  3641. extern int xfermode;
  3642. #ifdef VMS
  3643. s = "AUTOMATIC";
  3644. #else
  3645. if (xfermode == XMODE_A) {
  3646. s = "AUTOMATIC";
  3647. } else {
  3648. s = gfmode(binary,1);
  3649. }
  3650. if (!s) s = "";
  3651. #endif /* VMS */
  3652. if (*s)
  3653. printf("Default file-transfer mode is %s\n", s);
  3654. #endif /* COMMENT */
  3655. debug(F111,"herald","srvcdmsg",srvcdmsg);
  3656. if (srvcdmsg) {
  3657. for (i = 0; i < 8; i++) {
  3658. debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
  3659. if (zchki(cdmsgfile[i]) > -1) {
  3660. printf("\n");
  3661. dotype(cdmsgfile[i],
  3662. xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  3663. break;
  3664. }
  3665. }
  3666. }
  3667. printf("Type ? or HELP for help.\n");
  3668. }
  3669. }
  3670. }
  3671. /* G F M O D E -- Get File (transfer) Mode */
  3672. char *
  3673. gfmode(binary,upcase) int binary, upcase; {
  3674. char * s;
  3675. switch (binary) {
  3676. case XYFT_T: s = upcase ? "TEXT" : "text"; break;
  3677. #ifdef VMS
  3678. case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
  3679. case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
  3680. case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3681. case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
  3682. #else
  3683. #ifdef MAC
  3684. case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3685. case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
  3686. #else
  3687. case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
  3688. #ifdef CK_LABELED
  3689. case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
  3690. #endif /* CK_LABELED */
  3691. #endif /* MAC */
  3692. #endif /* VMS */
  3693. case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
  3694. default: s = "";
  3695. }
  3696. return(s);
  3697. }
  3698. #ifndef NOSPL
  3699. static int
  3700. isaa(s) char * s; { /* Is associative array */
  3701. char c;
  3702. int x;
  3703. if (!s) s = "";
  3704. if (!*s) return(0);
  3705. s++;
  3706. while ((c = *s++)) {
  3707. if (c == '<') {
  3708. x = strlen(s);
  3709. return ((*(s+x-1) == '>') ? 1 : 0);
  3710. }
  3711. }
  3712. return(0);
  3713. }
  3714. /* M L O O K -- Lookup the macro name in the macro table */
  3715. /*
  3716. Call this way: v = mlook(table,word,n);
  3717. table - a 'struct mtab' table.
  3718. word - the target string to look up in the table.
  3719. n - the number of elements in the table.
  3720. The keyword table must be arranged in ascending alphabetical order, and
  3721. all letters must be lowercase.
  3722. Returns the table index, 0 or greater, if the name was found, or:
  3723. -3 if nothing to look up (target was null),
  3724. -2 if ambiguous,
  3725. -1 if not found.
  3726. A match is successful if the target matches a keyword exactly, or if
  3727. the target is a prefix of exactly one keyword. It is ambiguous if the
  3728. target matches two or more keywords from the table.
  3729. */
  3730. int
  3731. mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
  3732. register int i;
  3733. int v, w, cmdlen = 0;
  3734. char c = 0, c1, * s;
  3735. if (!cmd) cmd = "";
  3736. for (s = cmd; *s; s++) cmdlen++; /* (instead of strlen) */
  3737. debug(F111,"MLOOK",cmd,cmdlen);
  3738. c1 = *cmd;
  3739. if (isupper(c1))
  3740. c1 = tolower(c1);
  3741. if (cmdlen < 1)
  3742. return(-3);
  3743. /* Not null, look it up */
  3744. if (n < 12) { /* Not worth it for small tables */
  3745. i = 0;
  3746. } else { /* Binary search for where to start */
  3747. int lo = 0;
  3748. int hi = n;
  3749. int count = 0;
  3750. while (lo+2 < hi && ++count < 12) {
  3751. i = lo + ((hi - lo) / 2);
  3752. c = *(table[i].kwd);
  3753. if (isupper(c)) c = tolower(c);
  3754. if (c < c1) {
  3755. lo = i;
  3756. } else {
  3757. hi = i;
  3758. }
  3759. }
  3760. i = (c < c1) ? lo+1 : lo;
  3761. }
  3762. for ( ; i < n-1; i++) {
  3763. s = table[i].kwd;
  3764. if (!s) s = "";
  3765. if (!*s) continue; /* Empty table entry */
  3766. c = *s;
  3767. if (isupper(c)) c = tolower(c);
  3768. if (c1 != c) continue; /* First char doesn't match */
  3769. if (!ckstrcmp(s,cmd,-1,0)) /* Have exact match? */
  3770. return(i);
  3771. v = !ckstrcmp(s,cmd,cmdlen,0);
  3772. w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
  3773. if (v && w) /* Have abbreviated match? */
  3774. return(i);
  3775. if (v) /* Ambiguous? */
  3776. return(-2);
  3777. if (w > 0) /* Past our alphabetic area? */
  3778. return(-1);
  3779. }
  3780. /* Last (or only) element */
  3781. if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
  3782. return(n-1);
  3783. return(-1);
  3784. }
  3785. /* mxlook is like mlook, but an exact full-length match is required */
  3786. int
  3787. mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3788. register int i;
  3789. int w, cmdlen = 0, one = 0;
  3790. register char c = 0, c1, * s;
  3791. if (!cmd) cmd = ""; /* Check args */
  3792. for (s = cmd; *s; s++) cmdlen++; /* (instead of strlen) */
  3793. debug(F111,"MXLOOK",cmd,cmdlen);
  3794. c1 = *cmd; /* First char of string to look up */
  3795. if (isupper(c1))
  3796. c1 = tolower(c1);
  3797. if (!*(cmd+1)) /* Special handling for 1-char names */
  3798. one = 1;
  3799. if (cmdlen < 1) /* Nothing to look up */
  3800. return(-3);
  3801. if (n < 12) { /* Not worth it for small tables */
  3802. i = 0;
  3803. } else { /* Binary search for where to start */
  3804. int lo = 0;
  3805. int hi = n;
  3806. int count = 0;
  3807. while (lo+2 < hi && ++count < 12) {
  3808. i = lo + ((hi - lo) / 2);
  3809. c = *(table[i].kwd);
  3810. if (isupper(c)) c = tolower(c);
  3811. if (c < c1) {
  3812. lo = i;
  3813. } else {
  3814. hi = i;
  3815. }
  3816. }
  3817. i = (c < c1) ? lo+1 : lo;
  3818. }
  3819. for ( ; i < n; i++) { /* Look thru table */
  3820. s = table[i].kwd; /* This entry */
  3821. if (!s) s = "";
  3822. if (!*s) continue; /* Empty table entry */
  3823. c = *s;
  3824. if (isupper(c)) c = tolower(c);
  3825. if (c1 != c) continue; /* First char doesn't match */
  3826. if (one) { /* Name is one char long */
  3827. if (!*(s+1))
  3828. return(i); /* So is table entry */
  3829. }
  3830. #ifdef COMMENT
  3831. if (((int)strlen(s) == cmdlen) &&
  3832. (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
  3833. #else
  3834. w = ckstrcmp(s,cmd,-1,0);
  3835. if (!w) {
  3836. debug(F111,"MXLOOK",mactab[i].mval,i);
  3837. return(i);
  3838. }
  3839. if (w > 0) return(-1);
  3840. #endif /* COMMENT */
  3841. }
  3842. return(-1);
  3843. }
  3844. /* mxxlook is like mxlook, but case-sensitive */
  3845. int
  3846. mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
  3847. int i, cmdlen;
  3848. if (!cmd) cmd = "";
  3849. if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
  3850. /* debug(F111,"mxxlook target",cmd,n); */
  3851. for (i = 0; i < n; i++) {
  3852. if (((int)strlen(table[i].kwd) == cmdlen) &&
  3853. (!strncmp(table[i].kwd,cmd,cmdlen)))
  3854. return(i);
  3855. }
  3856. return(-1);
  3857. }
  3858. static int
  3859. traceval(nam, val) char * nam, * val; { /* For TRACE command */
  3860. if (val)
  3861. printf(">>> %s: \"%s\"\n", nam, val);
  3862. else
  3863. printf(">>> %s: (undef)\n", nam);
  3864. return(0);
  3865. }
  3866. #ifdef USE_VARLEN /* Not used */
  3867. /* V A R L E N -- Get length of variable's value.
  3868. Given a variable name, return the length of its definition or 0 if the
  3869. variable is not defined. If it is defined, set argument s to point to its
  3870. definition. Otherwise set s to NULL.
  3871. */
  3872. int
  3873. varlen(nam,s) char *nam; char **s; { /* Length of value of variable */
  3874. int x, z;
  3875. char *p = NULL, c;
  3876. *s = NULL;
  3877. if (!nam) return(0); /* Watch out for null pointer */
  3878. if (*nam == CMDQ) {
  3879. nam++;
  3880. if (*nam == '%') { /* If it's a variable name */
  3881. if (!(c = *(nam+1))) return(0); /* Get letter or digit */
  3882. p = (char *)0; /* Initialize value pointer */
  3883. if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  3884. p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
  3885. } else { /* It's a global variable */
  3886. if (c < 33 || c > GVARS) return(0);
  3887. p = g_var[c]; /* Get pointer from global-var table */
  3888. }
  3889. } else if (*nam == '&') { /* An array reference? */
  3890. char **q;
  3891. if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  3892. return(-1); /* return -1. */
  3893. x -= ARRAYBASE; /* Convert name to number. */
  3894. if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  3895. return(0); /* return -2. */
  3896. if (z > a_dim[x]) /* If subscript out of range, */
  3897. return(0); /* return -3. */
  3898. p = q[z];
  3899. }
  3900. } else { /* Macro */
  3901. z = isaa(nam);
  3902. x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
  3903. if (x < 0)
  3904. return(0);
  3905. p = mactab[x].mval;
  3906. }
  3907. if (p)
  3908. *s = p;
  3909. else
  3910. p = "";
  3911. return((int)strlen(p));
  3912. }
  3913. #endif /* USE_VARLEN */
  3914. /*
  3915. This routine is for the benefit of those compilers that can't handle
  3916. long string constants or continued lines within them. Long predefined
  3917. macros like FOR, WHILE, and XIF have their contents broken up into
  3918. arrays of string pointers. This routine concatenates them back into a
  3919. single string again, and then calls the real addmac() routine to enter
  3920. the definition into the macro table.
  3921. */
  3922. int
  3923. addmmac(nam,s) char *nam, *s[]; { /* Add a multiline macro definition */
  3924. int i, x, y; char *p;
  3925. x = 0; /* Length counter */
  3926. for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
  3927. debug(F111,"addmmac line",s[i],y);
  3928. x += y;
  3929. }
  3930. debug(F101,"addmmac lines","",i);
  3931. debug(F101,"addmmac loop exit","",y);
  3932. debug(F111,"addmmac length",nam,x);
  3933. if (x < 0) return(-1);
  3934. p = malloc(x+1); /* Allocate space for all of it. */
  3935. if (!p) {
  3936. printf("?addmmac malloc error: %s\n",nam);
  3937. debug(F110,"addmmac malloc error",nam,0);
  3938. return(-1);
  3939. }
  3940. *p = '\0'; /* Start off with null string. */
  3941. for (i = 0; *s[i]; i++) /* Concatenate them all together. */
  3942. ckstrncat(p,s[i],x+1);
  3943. y = (int)strlen(p); /* Final precaution. */
  3944. debug(F111,"addmmac constructed string",p,y);
  3945. if (y == x) {
  3946. y = addmac(nam,p); /* Add result to the macro table. */
  3947. } else {
  3948. debug(F100,"addmmac length mismatch","",0);
  3949. printf("\n!addmmac internal error!\n");
  3950. y = -1;
  3951. }
  3952. free(p); /* Free the temporary copy. */
  3953. return(y);
  3954. }
  3955. static char evalmacrobuf[TMPBUFSIZ];
  3956. int
  3957. evalmacroarg(p) char **p; {
  3958. char * s = evalmacrobuf;
  3959. int t = TMPBUFSIZ;
  3960. (VOID) zzstring(*p,&s,&t);
  3961. *p = evalmacrobuf;
  3962. }
  3963. /* Here is the real addmac routine. */
  3964. /* Returns -1 on failure, macro table index >= 0 on success. */
  3965. int mtchanged = 0;
  3966. int
  3967. addmac(nam,def) char *nam, *def; { /* Add a macro to the macro table */
  3968. int i, x, y, z, namlen, deflen, flag = 0;
  3969. int replacing = 0, deleting = 0;
  3970. char * p = NULL, c, *s;
  3971. extern int tra_asg; int tra_tmp;
  3972. if (!nam) return(-1);
  3973. if (!*nam) return(-1);
  3974. #ifdef IKSD
  3975. if (inserver &&
  3976. #ifdef IKSDCONF
  3977. iksdcf
  3978. #else /* IKSDCONF */
  3979. 1
  3980. #endif /* IKSDCONF */
  3981. ) {
  3982. if (!ckstrcmp("on_exit",nam,-1,0) ||
  3983. !ckstrcmp("on_logout",nam,-1,0))
  3984. return(-1);
  3985. }
  3986. #endif /* IKSD */
  3987. namlen = 0;
  3988. p = nam;
  3989. while (*p++) namlen++; /* (instead of strlen) */
  3990. tra_tmp = tra_asg; /* trace... */
  3991. debug(F111,"addmac nam",nam,namlen);
  3992. if (!def) { /* Watch out for null pointer */
  3993. deflen = 0;
  3994. debug(F111,"addmac def","(null pointer)",deflen);
  3995. } else {
  3996. deflen = 0;
  3997. p = def;
  3998. while (*p++) deflen++; /* (instead of strlen) */
  3999. debug(F010,"addmac def",def,0);
  4000. }
  4001. #ifdef USE_VARLEN /* NOT USED */
  4002. /* This does not boost performance much because varlen() does a lot */
  4003. x = varlen(nam,&s);
  4004. if (x > 0 && x >= deflen) {
  4005. strcpy(s,def); /* NOT USED */
  4006. flag = 1;
  4007. p = s;
  4008. }
  4009. #endif /* USE_VARLEN */
  4010. if (*nam == CMDQ) nam++; /* Backslash quote? */
  4011. if (*nam == '%') { /* Yes, if it's a variable name, */
  4012. if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
  4013. if (!flag) {
  4014. tra_asg = 0;
  4015. delmac(nam,0); /* Delete any old value. */
  4016. tra_asg = tra_tmp;
  4017. }
  4018. if (deflen < 1) { /* Null definition */
  4019. p = NULL; /* Better not malloc or strcpy! */
  4020. } else if (!flag) { /* A substantial definition */
  4021. p = malloc(deflen + 1); /* Allocate space for it */
  4022. if (!p) {
  4023. printf("?addmac malloc error 2\n");
  4024. return(-1);
  4025. } else strcpy(p,def); /* Copy def into new space (SAFE) */
  4026. }
  4027. /* Now p points to the definition, or is a null pointer */
  4028. if (c >= '0' && c <= '9') { /* \%0-9 variable */
  4029. if (maclvl < 0) { /* Are we calling or in a macro? */
  4030. g_var[c] = p; /* No, it's top level one */
  4031. makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
  4032. } else { /* Yes, it's a macro argument */
  4033. m_arg[maclvl][c - '0'] = p; /* Assign the value */
  4034. makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
  4035. }
  4036. } else { /* It's a \%a-z variable */
  4037. if (c < 33 || (unsigned int)c > GVARS) return(-1);
  4038. if (isupper(c)) c = (char) tolower(c);
  4039. g_var[c] = p; /* Put pointer in global-var table */
  4040. }
  4041. if (tra_asg) traceval(nam,p);
  4042. return(0);
  4043. } else if (*nam == '&') { /* An array reference? */
  4044. char **q = NULL;
  4045. int rc = 0;
  4046. if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
  4047. return(-1); /* return -1. */
  4048. if (chkarray(x,z) < 0) /* If array not declared or */
  4049. rc = -2; /* subscript out of range, ret -2 */
  4050. if (!flag) {
  4051. tra_asg = 0;
  4052. delmac(nam,0); /* Delete any old value. */
  4053. tra_asg = tra_tmp;
  4054. }
  4055. x -= ARRAYBASE; /* Convert name letter to index. */
  4056. if (x > 'z' - ARRAYBASE + 1)
  4057. rc = -1;
  4058. if (rc != -1) {
  4059. if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4060. return(-3); /* return -3. */
  4061. }
  4062. if (rc < 0)
  4063. return(rc);
  4064. if (!flag) {
  4065. if (deflen > 0) {
  4066. if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
  4067. printf("addmac macro error 7: %s\n",nam);
  4068. return(-4); /* for new def, return -4 on fail. */
  4069. }
  4070. strcpy(p,def); /* Copy def into new space (SAFE). */
  4071. } else p = NULL;
  4072. }
  4073. q[z] = p; /* Store pointer to it. */
  4074. if (x == 0) { /* Arg vector array */
  4075. if (z >= 0 && z <= 9) { /* Copy values to corresponding */
  4076. if (maclvl < 0) { /* \%1..9 variables. */
  4077. makestr(&(toparg[z]),p);
  4078. } else {
  4079. makestr(&(m_arg[maclvl][z]),p);
  4080. }
  4081. }
  4082. }
  4083. if (tra_asg) traceval(nam,p);
  4084. return(0); /* Done. */
  4085. }
  4086. /* Not a macro argument or a variable, so it's a macro definition */
  4087. #ifdef USE_VARLEN
  4088. if (flag) {
  4089. if (tra_asg) traceval(nam,p);
  4090. return(0);
  4091. }
  4092. #endif /* USE_VARLEN */
  4093. x = isaa(nam) ? /* If it's an associative array */
  4094. mxxlook(mactab,nam,nmac) : /* look it up this way */
  4095. mxlook(mactab,nam,nmac); /* otherwise this way. */
  4096. if (x > -1) { /* If found... */
  4097. if (deflen > 0) /* and a new definition was given */
  4098. replacing = 1; /* we're replacing */
  4099. else /* otherwise */
  4100. deleting = 1; /* we're deleting */
  4101. }
  4102. if (deleting) { /* Deleting... */
  4103. if (delmac(nam,0) < 0)
  4104. return(-1);
  4105. mtchanged++;
  4106. if (tra_asg) traceval(nam,p);
  4107. return(0);
  4108. } else if (deflen < 1) /* New macro with no definition */
  4109. return(0); /* Nothing to do. */
  4110. if (replacing) { /* Replacing an existing macro */
  4111. if (mactab[x].mval) { /* If it currently has a definition, */
  4112. free(mactab[x].mval); /* free it. */
  4113. mactab[x].mval = NULL;
  4114. }
  4115. mtchanged++;
  4116. y = x; /* Replacement index. */
  4117. } else { /* Adding a new macro... */
  4118. char c1, c2; /* Use fast lookup to find the */
  4119. c1 = *nam; /* alphabetical slot. */
  4120. if (isupper(c1)) c1 = (char) tolower(c1);
  4121. if (nmac < 5) { /* Not worth it for small tables */
  4122. y = 0;
  4123. } else { /* First binary search to find */
  4124. int lo = 0; /* where to start */
  4125. int hi = nmac;
  4126. int count = 0;
  4127. char c = 0;
  4128. while (lo+2 < hi && ++count < 12) {
  4129. y = lo + ((hi - lo) / 2);
  4130. c = *(mactab[y].kwd);
  4131. if (isupper(c)) c = (char) tolower(c);
  4132. if (c < c1) {
  4133. lo = y;
  4134. } else {
  4135. hi = y;
  4136. }
  4137. }
  4138. y = (c < c1) ? lo+1 : lo;
  4139. }
  4140. /* Now search linearly from starting location */
  4141. for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
  4142. c2 = *(mactab[y].kwd);
  4143. if (isupper(c2)) c2 = (char) tolower(c2);
  4144. if (c1 > c2)
  4145. continue;
  4146. if (c1 < c2)
  4147. break;
  4148. if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
  4149. break;
  4150. }
  4151. if (y == MAC_MAX) { /* Macro table is full. */
  4152. debug(F101,"addmac table overflow","",y);
  4153. printf("?Macro table overflow\n");
  4154. return(-1);
  4155. }
  4156. if (mactab[y].kwd != NULL) { /* Must insert */
  4157. for (i = nmac; i > y; i--) { /* Move the rest down one slot */
  4158. mactab[i].kwd = mactab[i-1].kwd;
  4159. mactab[i].mval = mactab[i-1].mval;
  4160. mactab[i].flgs = mactab[i-1].flgs;
  4161. }
  4162. }
  4163. mtchanged++;
  4164. p = malloc(namlen + 1); /* Allocate space for name */
  4165. if (!p) {
  4166. printf("?Addmac: Out of memory - \"%s\"\n",nam);
  4167. return(-1);
  4168. }
  4169. strcpy(p,nam); /* Copy name into new space (SAFE) */
  4170. mactab[y].kwd = p; /* Add pointer to table */
  4171. }
  4172. if (deflen > 0) { /* If we have a definition */
  4173. p = malloc(deflen + 1); /* Get space */
  4174. if (p == NULL) {
  4175. printf("?Space exhausted - \"%s\"\n", nam);
  4176. if (mactab[y].kwd) {
  4177. free(mactab[y].kwd);
  4178. mactab[y].kwd = NULL;
  4179. }
  4180. return(-1);
  4181. } else {
  4182. strcpy(p,def); /* Copy the definition (SAFE) */
  4183. }
  4184. } else { /* definition is empty */
  4185. p = NULL;
  4186. }
  4187. mactab[y].mval = p; /* Macro points to definition */
  4188. mactab[y].flgs = 0; /* No flags */
  4189. if (!replacing) /* If new macro */
  4190. nmac++; /* count it */
  4191. if (tra_asg) traceval(nam,p);
  4192. return(y);
  4193. }
  4194. int
  4195. xdelmac(x) int x; { /* Delete a macro given its index */
  4196. int i;
  4197. extern int tra_asg;
  4198. if (x < 0) return(x);
  4199. if (tra_asg)
  4200. traceval(mactab[x].kwd,NULL);
  4201. if (mactab[x].kwd) { /* Free the storage for the name */
  4202. free(mactab[x].kwd);
  4203. mactab[x].kwd = NULL;
  4204. }
  4205. if (mactab[x].mval) { /* and for the definition */
  4206. free(mactab[x].mval);
  4207. mactab[x].mval = NULL;
  4208. }
  4209. for (i = x; i < nmac; i++) { /* Now move up the others. */
  4210. mactab[i].kwd = mactab[i+1].kwd;
  4211. mactab[i].mval = mactab[i+1].mval;
  4212. mactab[i].flgs = mactab[i+1].flgs;
  4213. }
  4214. nmac--; /* One less macro */
  4215. mactab[nmac].kwd = NULL; /* Delete last item from table */
  4216. mactab[nmac].mval = NULL;
  4217. mactab[nmac].flgs = 0;
  4218. mtchanged++;
  4219. return(0);
  4220. }
  4221. int
  4222. delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
  4223. int x, z;
  4224. char *p, c;
  4225. extern int tra_asg;
  4226. if (!nam) return(0); /* Watch out for null pointer */
  4227. debug(F110,"delmac nam",nam,0);
  4228. #ifdef IKSD
  4229. if ( inserver &&
  4230. #ifdef IKSDCONF
  4231. iksdcf
  4232. #else /* IKSDCONF */
  4233. 1
  4234. #endif /* IKSDCONF */
  4235. ) {
  4236. if (!ckstrcmp("on_exit",nam,-1,0) ||
  4237. !ckstrcmp("on_logout",nam,-1,0))
  4238. return(-1);
  4239. }
  4240. #endif /* IKSD */
  4241. if (*nam == CMDQ) nam++;
  4242. if (*nam == '%') { /* If it's a variable name */
  4243. if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
  4244. p = (char *)0; /* Initialize value pointer */
  4245. if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
  4246. p = toparg[c - '0'];
  4247. if (p) if (p != g_var[c]) {
  4248. free(p);
  4249. toparg[c - '0'] = NULL;
  4250. }
  4251. p = g_var[c];
  4252. g_var[c] = NULL; /* Zero the table entry */
  4253. } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
  4254. p = m_xarg[maclvl][c - '0'];
  4255. if (p) if (p != g_var[c]) {
  4256. free(p);
  4257. m_xarg[maclvl][c - '0'] = NULL;
  4258. }
  4259. p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
  4260. m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
  4261. } else { /* It's a global variable */
  4262. if (c < 33 || (unsigned int)c > GVARS) return(0);
  4263. p = g_var[c]; /* Get pointer from global-var table */
  4264. g_var[c] = NULL; /* Zero the table entry */
  4265. }
  4266. if (p) {
  4267. debug(F010,"delmac def",p,0);
  4268. free(p); /* Free the storage */
  4269. p = NULL;
  4270. } else debug(F110,"delmac def","(null pointer)",0);
  4271. if (tra_asg) traceval(nam,NULL);
  4272. return(0);
  4273. }
  4274. if (*nam == '&') { /* An array reference? */
  4275. char **q;
  4276. if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
  4277. return(-1); /* return -1. */
  4278. x -= ARRAYBASE; /* Convert name to number. */
  4279. if ((q = a_ptr[x]) == NULL) /* If array not declared, */
  4280. return(-2); /* return -2. */
  4281. if (z > a_dim[x]) /* If subscript out of range, */
  4282. return(-3); /* return -3. */
  4283. if (q[z]) { /* If there is an old value, */
  4284. debug(F010,"delmac def",q[z],0);
  4285. if (x != 0) /* Macro arg vector is just a copy */
  4286. free(q[z]); /* Others are real so free them */
  4287. q[z] = NULL;
  4288. if (x == 0) { /* Arg vector array */
  4289. if (z >= 0 && z <= 9) { /* Copy values to corresponding */
  4290. if (maclvl < 0) { /* \%1..9 variables. */
  4291. makestr(&(toparg[z]),NULL);
  4292. } else {
  4293. makestr(&(m_arg[maclvl][z]),NULL);
  4294. }
  4295. }
  4296. }
  4297. if (tra_asg) traceval(nam,NULL);
  4298. } else debug(F010,"delmac def","(null pointer)",0);
  4299. }
  4300. /* Not a variable or an array, so it must be a macro. */
  4301. z = isaa(nam);
  4302. debug(F111,"delmac isaa",nam,z);
  4303. debug(F111,"delmac exact",nam,exact);
  4304. x = z ? mxxlook(mactab,nam,nmac) :
  4305. exact ? mxlook(mactab,nam,nmac) :
  4306. mlook(mactab,nam,nmac);
  4307. if (x < 0) {
  4308. debug(F111,"delmac mlook",nam,x);
  4309. return(x);
  4310. }
  4311. return(xdelmac(x));
  4312. }
  4313. VOID
  4314. initmac() { /* Init macro & variable tables */
  4315. int i, j, x;
  4316. nmac = 0; /* No macros */
  4317. for (i = 0; i < MAC_MAX; i++) { /* Initialize the macro table */
  4318. mactab[i].kwd = NULL;
  4319. mactab[i].mval = NULL;
  4320. mactab[i].flgs = 0;
  4321. }
  4322. mtchanged++;
  4323. x = (MAXARGLIST + 1) * sizeof(char **);
  4324. for (i = 0; i < MACLEVEL; i++) { /* Init the macro argument tables */
  4325. m_xarg[i] = (char **) malloc(x);
  4326. mrval[i] = NULL; /* Macro return value */
  4327. /* Pointer to entire argument vector, level i, for \&_[] array */
  4328. for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
  4329. if (j < 10) /* For the \%0..\%9 variables */
  4330. m_arg[i][j] = NULL; /* Pointer to arg j, level i. */
  4331. if (m_xarg[i]) /* For \&_[] - all args. */
  4332. m_xarg[i][j] = NULL;
  4333. }
  4334. }
  4335. for (i = 0; i < GVARS; i++) { /* And the global variables table */
  4336. g_var[i] = NULL;
  4337. }
  4338. /* And the table of arrays */
  4339. for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
  4340. a_ptr[i] = (char **) NULL; /* Null pointer for each */
  4341. a_dim[i] = 0; /* and a dimension of zero */
  4342. a_link[i] = -1;
  4343. for (j = 0; j < CMDSTKL; j++) {
  4344. aa_ptr[j][i] = (char **) NULL;
  4345. aa_dim[j][i] = 0;
  4346. }
  4347. }
  4348. }
  4349. int
  4350. popclvl() { /* Pop command level, return cmdlvl */
  4351. extern int tra_cmd;
  4352. struct localvar * v;
  4353. int i, topcmd;
  4354. debug(F101,"popclvl cmdlvl","",cmdlvl);
  4355. if (cmdlvl > 0) {
  4356. if ((v = localhead[cmdlvl])) { /* Did we save any variables? */
  4357. while (v) { /* Yes */
  4358. if (v->lv_value) /* Copy old ones back */
  4359. addmac(v->lv_name,v->lv_value);
  4360. else
  4361. delmac(v->lv_name,1);
  4362. v = v->lv_next;
  4363. }
  4364. freelocal(cmdlvl); /* Free local storage */
  4365. }
  4366. /* Automatic arrays do not use the localhead list */
  4367. for (i = 0; i < 28; i++) { /* Free any local arrays */
  4368. if (aa_ptr[cmdlvl][i]) { /* Does this one exist? */
  4369. dclarray((char)(i+ARRAYBASE),-1); /* Destroy global one */
  4370. a_ptr[i] = aa_ptr[cmdlvl][i];
  4371. a_dim[i] = aa_dim[cmdlvl][i];
  4372. aa_ptr[cmdlvl][i] = (char **)NULL;
  4373. aa_dim[cmdlvl][i] = 0;
  4374. } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
  4375. /*
  4376. A local array declared at this level when there was no
  4377. array of the same name at any higher level. See comment
  4378. in pusharray().
  4379. */
  4380. dclarray((char)(i+ARRAYBASE),-1);
  4381. a_ptr[i] = (char **)NULL; /* Delete top-level array */
  4382. a_dim[i] = 0; /* created by pusharray - Feb 2016 */
  4383. aa_ptr[cmdlvl][i] = (char **)NULL;
  4384. aa_dim[cmdlvl][i] = 0;
  4385. }
  4386. /* Otherwise do nothing - it is a local array that was declared */
  4387. /* at a level above this one so leave it alone. */
  4388. }
  4389. }
  4390. if (cmdlvl < 1) { /* If we're already at top level */
  4391. cmdlvl = 0; /* just make sure all the */
  4392. tlevel = -1; /* stack pointers are set right */
  4393. maclvl = -1; /* and return */
  4394. } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
  4395. debug(F101,"popclvl tlevel","",tlevel);
  4396. if (tlevel > -1) { /* Yes, */
  4397. fclose(tfile[tlevel]); /* close it */
  4398. if (tra_cmd)
  4399. printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
  4400. debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
  4401. if (tfnam[tlevel]) { /* free storage for name */
  4402. free(tfnam[tlevel]);
  4403. tfnam[tlevel] = NULL;
  4404. }
  4405. tlevel--; /* and pop take level */
  4406. cmdlvl--; /* and command level */
  4407. quiet = xquiet[cmdlvl];
  4408. vareval = xvarev[cmdlvl];
  4409. } else
  4410. tlevel = -1;
  4411. } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
  4412. topcmd = lastcmd[maclvl];
  4413. debug(F101,"popclvl maclvl","",maclvl);
  4414. if (maclvl > -1) { /* Yes, */
  4415. #ifdef COMMENT
  4416. int i;
  4417. char **q;
  4418. #endif /* COMMENT */
  4419. macp[maclvl] = ""; /* set macro pointer to null string */
  4420. *cmdbuf = '\0'; /* clear the command buffer */
  4421. if ((maclvl > 0) && /* 2 May 1999 */
  4422. (m_arg[maclvl-1][0]) &&
  4423. (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  4424. !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  4425. !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
  4426. !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
  4427. mrval[maclvl+1]) {
  4428. makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
  4429. }
  4430. if (maclvl+1 < MACLEVEL) {
  4431. if (mrval[maclvl+1]) { /* Free any deeper return values. */
  4432. free(mrval[maclvl+1]);
  4433. mrval[maclvl+1] = NULL;
  4434. }
  4435. }
  4436. if (tra_cmd)
  4437. printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
  4438. debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);
  4439. maclvl--; /* Pop macro level */
  4440. cmdlvl--; /* and command level */
  4441. debug(F101,"popclvl mac new maclvl","",maclvl);
  4442. debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);
  4443. quiet = xquiet[cmdlvl];
  4444. vareval = xvarev[cmdlvl];
  4445. if (maclvl > -1) {
  4446. a_ptr[0] = m_xarg[maclvl];
  4447. a_dim[0] = n_xarg[maclvl] - 1;
  4448. debug(F111,"a_dim[0]","B",a_dim[0]);
  4449. } else {
  4450. a_ptr[0] = topxarg;
  4451. a_dim[0] = topargc - 1;
  4452. debug(F111,"a_dim[0]","C",a_dim[0]);
  4453. }
  4454. } else {
  4455. maclvl = -1;
  4456. }
  4457. #ifndef NOSEXP
  4458. debug(F101,"popclvl topcmd","",topcmd);
  4459. if (topcmd == XXSEXP) {
  4460. extern char * sexpval;
  4461. makestr(&(mrval[maclvl+1]),sexpval);
  4462. }
  4463. #endif /* NOSEXP */
  4464. } else {
  4465. cmdlvl--;
  4466. }
  4467. debug(F101,"popclvl cmdlvl","",cmdlvl);
  4468. if (prstring[cmdlvl]) {
  4469. cmsetp(prstring[cmdlvl]);
  4470. makestr(&(prstring[cmdlvl]),NULL);
  4471. }
  4472. #ifndef MAC
  4473. if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
  4474. setint();
  4475. concb((char)escape); /* Go into cbreak mode */
  4476. }
  4477. #endif /* MAC */
  4478. xcmdsrc = cmdstk[cmdlvl].src;
  4479. debug(F101,"popclvl xcmdsrc","",xcmdsrc);
  4480. debug(F101,"popclvl tlevel","",tlevel);
  4481. return(cmdlvl < 1 ? 0 : cmdlvl); /* Return command level */
  4482. }
  4483. #else /* No script programming language */
  4484. int popclvl() { /* Just close current take file. */
  4485. if (tlevel > -1) { /* if any... */
  4486. if (tfnam[tlevel]) {
  4487. free(tfnam[tlevel]);
  4488. tfnam[tlevel] = NULL;
  4489. }
  4490. fclose(tfile[tlevel--]);
  4491. }
  4492. if (tlevel == -1) { /* And if back at top level */
  4493. setint();
  4494. concb((char)escape); /* and go back into cbreak mode. */
  4495. }
  4496. xcmdsrc = tlevel > -1 ? CMD_TF : 0;
  4497. return(tlevel + 1);
  4498. }
  4499. #endif /* NOSPL */
  4500. #ifndef NOSPL
  4501. static int
  4502. iseom(m) char * m; { /* Test if at end of macro def */
  4503. if (!m)
  4504. m = "";
  4505. debug(F111,"iseom",m,maclvl);
  4506. while (*m) {
  4507. /* Anything but Space and Comma means more macro is left */
  4508. if ((*m > SP) && (*m != ',')) {
  4509. debug(F111,"iseom return",m,0);
  4510. return(0);
  4511. }
  4512. m++;
  4513. }
  4514. debug(F111,"iseom return",m,1);
  4515. return(1); /* Nothing left */
  4516. }
  4517. #endif /* NOSPL */
  4518. /* Pop all command levels that can be popped */
  4519. int
  4520. prepop() {
  4521. if (cmdlvl > 0) { /* If command level is > 0 and... */
  4522. while (
  4523. #ifndef NOSPL
  4524. ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
  4525. #endif /* NOSPL */
  4526. (tlevel > -1) &&
  4527. feof(tfile[tlevel])) /* And at end of file... */
  4528. #ifndef NOSPL
  4529. /* Or command source is macro... */
  4530. || ((cmdstk[cmdlvl].src == CMD_MD) &&
  4531. (maclvl > -1) &&
  4532. iseom(macp[maclvl]))) /* and at end of macro, then... */
  4533. #endif /* NOSPL */
  4534. {
  4535. popclvl(); /* pop command level. */
  4536. }
  4537. }
  4538. return(cmdlvl < 1 ? 0 : cmdlvl); /* Return command level */
  4539. }
  4540. /* STOP - get back to C-Kermit prompt, no matter where from. */
  4541. int
  4542. dostop() {
  4543. extern int cmddep;
  4544. while (popclvl()) ; /* Pop all macros & take files */
  4545. #ifndef NOSPL
  4546. if (cmddep > -1) /* And all recursive cmd pkg invocations */
  4547. while (cmpop() > -1) ;
  4548. #endif /* NOSPL */
  4549. cmini(ckxech); /* Clear the command buffer. */
  4550. return(0);
  4551. }
  4552. /* Close the given log */
  4553. int
  4554. doclslog(x) int x; {
  4555. int y;
  4556. switch (x) {
  4557. #ifdef DEBUG
  4558. case LOGD:
  4559. if (deblog <= 0) {
  4560. printf("?Debugging log wasn't open\n");
  4561. return(0);
  4562. }
  4563. debug(F100,"Debug Log Closed","",0L);
  4564. *debfil = '\0';
  4565. deblog = 0;
  4566. return(zclose(ZDFILE));
  4567. #endif /* DEBUG */
  4568. #ifndef NOXFER
  4569. case LOGP:
  4570. if (pktlog <= 0) {
  4571. printf("?Packet log wasn't open\n");
  4572. return(0);
  4573. }
  4574. *pktfil = '\0';
  4575. pktlog = 0;
  4576. return(zclose(ZPFILE));
  4577. #endif /* NOXFER */
  4578. #ifndef NOLOCAL
  4579. case LOGS:
  4580. if (seslog <= 0) {
  4581. printf("?Session log wasn't open\n");
  4582. return(0);
  4583. }
  4584. *sesfil = '\0';
  4585. setseslog(0);
  4586. return(zclose(ZSFILE));
  4587. #endif /* NOLOCAL */
  4588. #ifdef TLOG
  4589. case LOGT: {
  4590. #ifdef IKSD
  4591. extern int iklogopen, xferlog;
  4592. #endif /* IKSD */
  4593. if (tralog <= 0
  4594. #ifdef IKSD
  4595. && !iklogopen
  4596. #endif /* IKSD */
  4597. ) {
  4598. if (msgflg)
  4599. printf("?Transaction log wasn't open\n");
  4600. return(0);
  4601. }
  4602. #ifdef IKSD
  4603. if (iklogopen && !inserver) {
  4604. close(xferlog);
  4605. iklogopen = 0;
  4606. }
  4607. #endif /* IKSD */
  4608. if (tralog) {
  4609. tlog(F100,"Transaction Log Closed","",0L);
  4610. zclose(ZTFILE);
  4611. }
  4612. *trafil = '\0';
  4613. tralog = 0;
  4614. return(1);
  4615. }
  4616. #endif /* TLOG */
  4617. #ifdef CKLOGDIAL
  4618. case LOGM:
  4619. if (dialog <= 0) {
  4620. if (msgflg) printf("?Connection log wasn't open\n");
  4621. return(0);
  4622. }
  4623. *diafil = '\0';
  4624. dialog = 0;
  4625. return(zclose(ZDIFIL));
  4626. #endif /* CKLOGDIAL */
  4627. #ifndef NOSPL
  4628. case LOGW: /* WRITE file */
  4629. case LOGR: /* READ file */
  4630. y = (x == LOGR) ? ZRFILE : ZWFILE;
  4631. if (chkfn(y) < 1) /* If no file to close */
  4632. return(1); /* succeed silently. */
  4633. return(zclose(y)); /* Otherwise, close the file. */
  4634. #endif /* NOSPL */
  4635. default:
  4636. printf("\n?Unexpected log designator - %d\n", x);
  4637. return(0);
  4638. }
  4639. }
  4640. static int slc = 0; /* Screen line count */
  4641. char *
  4642. showstring(s) char * s; {
  4643. return(s ? s : "(null)");
  4644. }
  4645. char *
  4646. showoff(x) int x; {
  4647. return(x ? "on" : "off");
  4648. }
  4649. char *
  4650. showooa(x) int x; {
  4651. switch (x) {
  4652. case SET_OFF: return("off");
  4653. case SET_ON: return("on");
  4654. case SET_AUTO: return("automatic");
  4655. default: return("(unknown)");
  4656. }
  4657. }
  4658. #ifdef GEMDOS
  4659. isxdigit(c) int c; {
  4660. return(isdigit(c) ||
  4661. (c >= 'a' && c <= 'f') ||
  4662. (c >= 'A' && c <= 'F'));
  4663. }
  4664. #endif /* GEMDOS */
  4665. #ifndef NOSETKEY
  4666. #ifdef OS2
  4667. static struct keytab shokeytab[] = { /* SHOW KEY modes */
  4668. "all", 1, 0,
  4669. "one", 0, 0
  4670. };
  4671. static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));
  4672. #define SHKEYDEF TT_MAX+5
  4673. struct keytab shokeymtab[] = {
  4674. "aaa", TT_AAA, CM_INV, /* AnnArbor */
  4675. "adm3a", TT_ADM3A, 0, /* LSI ADM-3A */
  4676. "adm5", TT_ADM5, 0, /* LSI ADM-5 */
  4677. "aixterm", TT_AIXTERM, 0, /* IBM AIXterm */
  4678. "annarbor", TT_AAA, 0, /* AnnArbor */
  4679. "ansi-bbs", TT_ANSI, 0, /* ANSI.SYS (BBS) */
  4680. "at386", TT_AT386, 0, /* Unixware ANSI */
  4681. "avatar/0+", TT_ANSI, 0, /* AVATAR/0+ */
  4682. "ba80", TT_BA80, 0, /* Nixdorf BA80 */
  4683. "be", TT_BEOS, CM_INV|CM_ABR,
  4684. "beos-ansi", TT_BEOS, CM_INV, /* BeOS ANSI */
  4685. "beterm", TT_BEOS, 0, /* BeOS Console */
  4686. "d200", TT_DG200, CM_INV|CM_ABR, /* Data General DASHER 200 */
  4687. "d210", TT_DG210, CM_INV|CM_ABR, /* Data General DASHER 210 */
  4688. "d217", TT_DG217, CM_INV|CM_ABR, /* Data General DASHER 217 */
  4689. "default", SHKEYDEF, 0,
  4690. "dg200", TT_DG200, 0, /* Data General DASHER 200 */
  4691. "dg210", TT_DG210, 0, /* Data General DASHER 210 */
  4692. "dg217", TT_DG217, 0, /* Data General DASHER 217 */
  4693. "emacs", TT_KBM_EMACS, 0, /* Emacs mode */
  4694. "h19", TT_H19, CM_INV, /* Heath-19 */
  4695. "heath19", TT_H19, 0, /* Heath-19 */
  4696. "hebrew", TT_KBM_HEBREW, 0, /* Hebrew mode */
  4697. "hft", TT_HFT, 0, /* IBM HFT */
  4698. "hp2621a", TT_HP2621, 0, /* HP 2621A */
  4699. "hpterm", TT_HPTERM, 0, /* HP TERM */
  4700. "hz1500", TT_HZL1500, 0, /* Hazeltine 1500 */
  4701. "ibm3151", TT_IBM31, 0, /* IBM 3101-xx,3161 */
  4702. "linux", TT_LINUX, 0, /* Linux */
  4703. "qansi", TT_QANSI, 0, /* QNX ANSI */
  4704. "qnx", TT_QNX, 0, /* QNX */
  4705. "russian", TT_KBM_RUSSIAN, 0, /* Russian mode */
  4706. "scoansi", TT_SCOANSI, 0, /* SCO ANSI */
  4707. "sni-97801", TT_97801, 0, /* Sinix 97801 */
  4708. "sun", TT_SUN, 0, /* Sun Console */
  4709. #ifdef OS2PM
  4710. #ifdef COMMENT
  4711. "tek4014", TT_TEK40, 0,
  4712. #endif /* COMMENT */
  4713. #endif /* OS2PM */
  4714. "tty", TT_NONE, 0,
  4715. "tvi910+", TT_TVI910, 0,
  4716. "tvi925", TT_TVI925, 0,
  4717. "tvi950", TT_TVI950, 0,
  4718. "vc404", TT_VC4404, 0,
  4719. "vc4404", TT_VC4404, CM_INV,
  4720. "vip7809", TT_VIP7809, 0,
  4721. "vt100", TT_VT100, 0,
  4722. "vt102", TT_VT102, 0,
  4723. "vt220", TT_VT220, 0,
  4724. "vt220pc", TT_VT220PC, 0,
  4725. "vt320", TT_VT320, 0,
  4726. "vt320pc", TT_VT320PC, 0,
  4727. "vt52", TT_VT52, 0,
  4728. "wp", TT_KBM_WP, 0,
  4729. "wy160", TT_WY160, 0,
  4730. "wy30", TT_WY30, 0,
  4731. "wy370", TT_WY370, 0,
  4732. "wy50", TT_WY50, 0,
  4733. "wy60", TT_WY60, 0,
  4734. "wyse30", TT_WY30, CM_INV,
  4735. "wyse370", TT_WY370, CM_INV,
  4736. "wyse50", TT_WY50, CM_INV,
  4737. "wyse60", TT_WY60, CM_INV
  4738. };
  4739. int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
  4740. #endif /* OS2 */
  4741. VOID
  4742. #ifdef OS2
  4743. shokeycode(c,m) int c, m;
  4744. #else
  4745. shokeycode(c) int c;
  4746. #endif
  4747. /* shokeycode */ {
  4748. KEY ch;
  4749. CHAR *s;
  4750. #ifdef OS2
  4751. int i;
  4752. con_event km;
  4753. #else /* OS2 */
  4754. int km;
  4755. #endif /* OS2 */
  4756. #ifdef OS2
  4757. extern int mskkeys;
  4758. char * mstr = "";
  4759. if (c >= KMSIZE) {
  4760. bleep(BP_FAIL);
  4761. return;
  4762. }
  4763. #else /* OS2 */
  4764. printf(" Key code \\%d => ", c);
  4765. #endif /* OS2 */
  4766. #ifndef OS2
  4767. km = mapkey(c);
  4768. #ifndef NOKVERBS
  4769. if (IS_KVERB(km)) { /* \Kverb? */
  4770. int i, kv;
  4771. kv = km & ~(F_KVERB);
  4772. printf("Verb: ");
  4773. for (i = 0; i < nkverbs; i++)
  4774. if (kverbs[i].kwval == kv) {
  4775. printf("\\K%s",kverbs[i].kwd);
  4776. break;
  4777. }
  4778. printf("\n");
  4779. } else
  4780. #endif /* NOKVERBS */
  4781. if (IS_CSI(km)) {
  4782. int xkm = km & 0xFF;
  4783. if (xkm <= 32 || xkm >= 127)
  4784. printf("String: \\{27}[\\{%d}\n",xkm);
  4785. else
  4786. printf("String: \\{27}[%c\n",xkm);
  4787. } else if (IS_ESC(km)) {
  4788. int xkm = km & 0xFF;
  4789. if (xkm <= 32 || xkm >= 127)
  4790. printf("String: \\{27}\\{%d}\n",xkm);
  4791. else
  4792. printf("String: \\{27}%c\n",xkm);
  4793. } else if (macrotab[c]) { /* See if there's a macro */
  4794. printf("String: "); /* If so, display its definition */
  4795. s = macrotab[c];
  4796. shostrdef(s);
  4797. printf("\n");
  4798. #ifndef NOKVERBS
  4799. } else if (km >= 0x100) { /* This means "undefined" */
  4800. printf("Undefined\n");
  4801. #endif /* NOKVERBS */
  4802. } else { /* No macro, show single character */
  4803. printf("Character: ");
  4804. ch = km;
  4805. if (ch < 32 || ch == 127
  4806. #ifdef OS2
  4807. || ch > 255
  4808. #endif /* OS2 */
  4809. #ifndef NEXT
  4810. #ifndef AUX
  4811. #ifndef XENIX
  4812. #ifndef OS2
  4813. || (ch > 127 && ch < 160)
  4814. #endif /* OS2 */
  4815. #endif /* XENIX */
  4816. #endif /* AUX */
  4817. #endif /* NEXT */
  4818. )
  4819. /*
  4820. These used to be %d, but gcc 1.93 & later complain about type mismatches.
  4821. %u is supposed to be totally portable.
  4822. */
  4823. printf("\\%u",(unsigned int) ch);
  4824. else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  4825. if (ch == (KEY) c)
  4826. printf(" (self, no translation)\n");
  4827. else
  4828. printf("\n");
  4829. }
  4830. #else /* OS2 */
  4831. if (m < 0) {
  4832. km = mapkey(c);
  4833. mstr = "default";
  4834. } else {
  4835. km = maptermkey(c,m);
  4836. for (i = 0; i < nshokeym; i++) {
  4837. if (m == shokeymtab[i].kwval) {
  4838. mstr = shokeymtab[i].kwd;
  4839. break;
  4840. }
  4841. }
  4842. }
  4843. s = keyname(c);
  4844. debug(F111,"shokeycode mstr",mstr,m);
  4845. debug(F111,"shokeycode keyname",s,c);
  4846. printf(" %sKey code \\%d %s (%s) => ",
  4847. mskkeys ? "mskermit " : "",
  4848. mskkeys ? cktomsk(c) : c,
  4849. s == NULL ? "" : s, mstr);
  4850. switch (km.type) {
  4851. #ifndef NOKVERBS
  4852. case kverb: {
  4853. int i, kv;
  4854. kv = km.kverb.id & ~(F_KVERB);
  4855. printf("Verb: ");
  4856. for (i = 0; i < nkverbs; i++) {
  4857. if (kverbs[i].kwval == kv) {
  4858. printf("\\K%s",kverbs[i].kwd);
  4859. break;
  4860. }
  4861. }
  4862. printf("\n");
  4863. break;
  4864. }
  4865. #endif /* NOKVERBS */
  4866. case csi: {
  4867. int xkm = km.csi.key & 0xFF;
  4868. if (xkm <= 32 || xkm >= 127)
  4869. printf("String: \\{27}[\\{%d}\n",xkm);
  4870. else
  4871. printf("String: \\{27}[%c\n",xkm);
  4872. break;
  4873. }
  4874. case esc: {
  4875. int xkm = km.esc.key & 0xFF;
  4876. if (xkm <= 32 || xkm >= 127)
  4877. printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
  4878. else
  4879. printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
  4880. break;
  4881. }
  4882. case macro: {
  4883. printf("String: "); /* Macro, display its definition */
  4884. shostrdef(km.macro.string);
  4885. printf("\n");
  4886. break;
  4887. }
  4888. case literal: {
  4889. printf("Literal string: "); /* Literal, display its definition */
  4890. shostrdef(km.literal.string);
  4891. printf("\n");
  4892. break;
  4893. }
  4894. case error: {
  4895. if (c >= 0x100) {
  4896. printf("Undefined\n");
  4897. } else {
  4898. printf("Character: ");
  4899. ch = c;
  4900. if (ch < 32 || ch == 127 || ch > 255
  4901. #ifndef NEXT
  4902. #ifndef AUX
  4903. #ifndef XENIX
  4904. #ifndef OS2
  4905. || (ch > 127 && ch < 160)
  4906. #endif /* OS2 */
  4907. #endif /* XENIX */
  4908. #endif /* AUX */
  4909. #endif /* NEXT */
  4910. )
  4911. /*
  4912. These used to be %d, but gcc 1.93 & later complain about type mismatches.
  4913. %u is supposed to be totally portable.
  4914. */
  4915. printf("\\%u",(unsigned int) ch);
  4916. else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  4917. printf(" (self, no translation)\n");
  4918. }
  4919. break;
  4920. }
  4921. case key: {
  4922. printf("Character: ");
  4923. ch = km.key.scancode;
  4924. if (ch < 32 || ch == 127 || ch > 255
  4925. #ifndef NEXT
  4926. #ifndef AUX
  4927. #ifndef XENIX
  4928. #ifndef OS2
  4929. || (ch > 127 && ch < 160)
  4930. #else
  4931. || (ch > 127)
  4932. #endif /* OS2 */
  4933. #endif /* XENIX */
  4934. #endif /* AUX */
  4935. #endif /* NEXT */
  4936. )
  4937. /*
  4938. These used to be %d, but gcc 1.93 & later complain about type mismatches.
  4939. %u is supposed to be totally portable.
  4940. */
  4941. printf("\\%u",(unsigned int) ch);
  4942. else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
  4943. if (ch == (KEY) c)
  4944. printf(" (self, no translation)\n");
  4945. else
  4946. printf("\n");
  4947. break;
  4948. }
  4949. }
  4950. #endif /* OS2 */
  4951. }
  4952. #endif /* NOSETKEY */
  4953. VOID
  4954. shostrdef(s) CHAR * s; {
  4955. CHAR ch;
  4956. if (!s) s = (CHAR *)"";
  4957. while ((ch = *s++)) {
  4958. if (ch < 32 || ch == 127 || ch == 255
  4959. /*
  4960. Systems whose native character sets have graphic characters in C1...
  4961. */
  4962. #ifndef NEXT /* NeXT */
  4963. #ifndef AUX /* Macintosh */
  4964. #ifndef XENIX /* IBM PC */
  4965. #ifdef OS2
  4966. /*
  4967. It doesn't matter whether the local host can display 8-bit characters;
  4968. they are not portable among character-sets and fonts. Who knows what
  4969. would be displayed...
  4970. */
  4971. || (ch > 127)
  4972. #else /* OS2 */
  4973. || (ch > 127 && ch < 160)
  4974. #endif /* OS2 */
  4975. #endif /* XENIX */
  4976. #endif /* AUX */
  4977. #endif /* NEXT */
  4978. )
  4979. printf("\\{%d}",ch); /* Display control characters */
  4980. else putchar((char) ch); /* in backslash notation */
  4981. }
  4982. }
  4983. #define xxdiff(v,sys) strncmp(v,sys,strlen(sys))
  4984. #ifndef NOSHOW
  4985. VOID
  4986. shover() {
  4987. #ifdef OS2
  4988. extern char ckxsystem[];
  4989. #endif /* OS2 */
  4990. extern char *ck_patch, * cklibv;
  4991. printf("\nVersions:\n %s\n",versio);
  4992. printf(" Numeric: %ld\n",vernum);
  4993. #ifdef OS2
  4994. printf(" Operating System: %s\n", ckxsystem);
  4995. #else /* OS2 */
  4996. printf(" Built for: %s\n", ckxsys);
  4997. #ifdef CK_UTSNAME
  4998. if (unm_nam[0])
  4999. printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
  5000. #endif /* CK_UTSNAME */
  5001. printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
  5002. #endif /* OS2 */
  5003. if (xxdiff(ckxv,ckxsys))
  5004. printf(" %s for%s\n",ckxv,ckxsys);
  5005. else
  5006. printf(" %s\n",ckxv);
  5007. if (xxdiff(ckzv,ckzsys))
  5008. printf(" %s for%s\n",ckzv,ckzsys);
  5009. else
  5010. printf(" %s\n",ckzv);
  5011. printf(" %s\n",cklibv);
  5012. printf(" %s\n",protv);
  5013. printf(" %s\n",fnsv);
  5014. printf(" %s\n %s\n",cmdv,userv);
  5015. #ifndef NOCSETS
  5016. printf(" %s\n",xlav);
  5017. #endif /* NOCSETS */
  5018. #ifndef MAC
  5019. #ifndef NOLOCAL
  5020. printf(" %s\n",connv);
  5021. #ifdef OS2
  5022. printf(" %s\n",ckyv);
  5023. #endif /* OS2 */
  5024. #endif /* NOLOCAL */
  5025. #endif /* MAC */
  5026. #ifndef NODIAL
  5027. printf(" %s\n",dialv);
  5028. #endif /* NODIAL */
  5029. #ifndef NOSCRIPT
  5030. printf(" %s\n",loginv);
  5031. #endif /* NOSCRIPT */
  5032. #ifdef NETCONN
  5033. printf(" %s\n",cknetv);
  5034. #ifdef OS2
  5035. printf(" %s\n",ckonetv);
  5036. #ifdef CK_NETBIOS
  5037. printf(" %s\n",ckonbiv);
  5038. #endif /* CK_NETBIOS */
  5039. #endif /* OS2 */
  5040. #endif /* NETCONN */
  5041. #ifdef TNCODE
  5042. printf(" %s\n",cktelv);
  5043. #endif /* TNCODE */
  5044. #ifdef SSHBUILTIN
  5045. printf(" %s\n",cksshv);
  5046. #ifdef SFTP_BUILTIN
  5047. printf(" %s\n",cksftpv);
  5048. #endif /* SFTP_BUILTIN */
  5049. #endif /* SSHBUILTIN */
  5050. #ifdef OS2
  5051. #ifdef OS2MOUSE
  5052. printf(" %s\n",ckomouv);
  5053. #endif /* OS2MOUSE */
  5054. #endif /* OS2 */
  5055. #ifdef NEWFTP
  5056. printf(" %s\n",ckftpv);
  5057. #endif /* NEWFTP */
  5058. #ifdef CK_AUTHENTICATION
  5059. printf(" %s\n",ckathv);
  5060. #endif /* CK_AUTHENTICATION */
  5061. #ifdef CK_ENCRYPTION
  5062. #ifdef CRYPT_DLL
  5063. printf(" %s\n",ck_crypt_dll_version());
  5064. #else /* CRYPT_DLL */
  5065. printf(" %s\n",ckcrpv);
  5066. #endif /* CRYPT_DLL */
  5067. #endif /* CK_ENCRYPTION */
  5068. #ifdef CK_SSL
  5069. printf(" %s\n",cksslv);
  5070. #endif /* CK_SSL */
  5071. printf("\n");
  5072. }
  5073. #ifdef CK_LABELED
  5074. VOID
  5075. sholbl() {
  5076. #ifdef VMS
  5077. printf("VMS Labeled File Features:\n");
  5078. printf(" acl %s (ACL info %s)\n",
  5079. showoff(lf_opts & LBL_ACL),
  5080. lf_opts & LBL_ACL ? "preserved" : "discarded");
  5081. printf(" backup-date %s (backup date/time %s)\n",
  5082. showoff(lf_opts & LBL_BCK),
  5083. lf_opts & LBL_BCK ? "preserved" : "discarded");
  5084. printf(" name %s (original filename %s)\n",
  5085. showoff(lf_opts & LBL_NAM),
  5086. lf_opts & LBL_NAM ? "preserved" : "discarded");
  5087. printf(" owner %s (original file owner id %s)\n",
  5088. showoff(lf_opts & LBL_OWN),
  5089. lf_opts & LBL_OWN ? "preserved" : "discarded");
  5090. printf(" path %s (original file's disk:[directory] %s)\n",
  5091. showoff(lf_opts & LBL_PTH),
  5092. lf_opts & LBL_PTH ? "preserved" : "discarded");
  5093. #else
  5094. #ifdef OS2
  5095. printf("OS/2 Labeled File features (attributes):\n");
  5096. printf(" archive: %s\n", showoff(lf_opts & LBL_ARC));
  5097. printf(" extended: %s\n", showoff(lf_opts & LBL_EXT));
  5098. printf(" hidden: %s\n", showoff(lf_opts & LBL_HID));
  5099. printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
  5100. printf(" system: %s\n", showoff(lf_opts & LBL_SYS));
  5101. #endif /* OS2 */
  5102. #endif /* VMS */
  5103. }
  5104. #endif /* CK_LABELED */
  5105. VOID
  5106. shotcs(csl,csr) int csl, csr; { /* Show terminal character set */
  5107. #ifndef NOCSETS
  5108. #ifdef OS2
  5109. #ifndef NOTERM
  5110. extern struct _vtG G[4], *GL, *GR;
  5111. extern int decnrcm, sni_chcode;
  5112. extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
  5113. extern prncs;
  5114. printf(" Terminal character-sets:\n");
  5115. if (IS97801(tt_type_mode)) {
  5116. if (cmask == 0377)
  5117. printf(" Mode: 8-bit Mode\n");
  5118. else
  5119. printf(" Mode: 7-bit Mode\n");
  5120. printf(" CH.CODE is %s\n",sni_chcode?"On":"Off");
  5121. } else if (ISVT100(tt_type_mode)) {
  5122. if (decnrcm)
  5123. printf(" Mode: 7-bit National Mode\n");
  5124. else
  5125. printf(" Mode: 8-bit Multinational Mode\n");
  5126. }
  5127. if ( isunicode() )
  5128. printf(" Local: Unicode display / %s input\n",
  5129. csl == TX_TRANSP ? "transparent" :
  5130. csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5131. else
  5132. printf(" Local: %s\n",
  5133. csl == TX_TRANSP ? "transparent" :
  5134. csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
  5135. if ( tt_utf8 ) {
  5136. printf(" Remote: UTF-8\n");
  5137. } else {
  5138. printf(" Remote: %sG0: %s (%s)\n",
  5139. GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : " ",
  5140. txrinfo[G[0].designation]->keywd,
  5141. G[0].designation == TX_TRANSP ? "" :
  5142. G[0].size == cs94 ? "94 chars" :
  5143. G[0].size == cs96 ? "96 chars" : "multi-byte");
  5144. printf(" %sG1: %s (%s)\n",
  5145. GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : " ",
  5146. txrinfo[G[1].designation]->keywd,
  5147. G[1].designation == TX_TRANSP ? "" :
  5148. G[1].size == cs94 ? "94 chars" :
  5149. G[1].size == cs96 ? "96 chars" : "multi-byte");
  5150. printf(" %sG2: %s (%s)\n",
  5151. GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : " ",
  5152. txrinfo[G[2].designation]->keywd,
  5153. G[2].designation == TX_TRANSP ? "" :
  5154. G[2].size == cs94 ? "94 chars" :
  5155. G[2].size == cs96 ? "96 chars" : "multi-byte");
  5156. printf(" %sG3: %s (%s)\n",
  5157. GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : " ",
  5158. txrinfo[G[3].designation]->keywd,
  5159. G[3].designation == TX_TRANSP ? "" :
  5160. G[3].size == cs94 ? "94 chars" :
  5161. G[3].size == cs96 ? "96 chars" : "multi-byte");
  5162. }
  5163. printf("\n");
  5164. printf(" Keyboard character-sets:\n");
  5165. printf(" Multinational: %s\n",txrinfo[dec_kbd]->keywd);
  5166. printf(" National: %s\n",txrinfo[dec_nrc]->keywd);
  5167. printf("\n");
  5168. printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
  5169. #endif /* NOTERM */
  5170. #else /* OS2 */
  5171. #ifndef MAC
  5172. char *s;
  5173. debug(F101,"TERM LOCAL CSET","",csl);
  5174. debug(F101,"TERM REMOTE CSET","",csr);
  5175. printf(" Terminal character-set: ");
  5176. if (tcs_transp) { /* No translation */
  5177. printf("transparent\n");
  5178. } else { /* Translation */
  5179. printf("%s (remote) %s (local)\n",
  5180. fcsinfo[csr].keyword,fcsinfo[csl].keyword);
  5181. if (csr != csl) {
  5182. switch(gettcs(csr,csl)) {
  5183. case TC_USASCII: s = "ascii"; break;
  5184. case TC_1LATIN: s = "latin1-iso"; break;
  5185. case TC_2LATIN: s = "latin2-iso"; break;
  5186. case TC_CYRILL: s = "cyrillic-iso"; break;
  5187. case TC_JEUC: s = "japanese-euc"; break;
  5188. case TC_HEBREW: s = "hebrew-iso"; break;
  5189. case TC_GREEK: s = "greek-iso"; break;
  5190. case TC_9LATIN: s = "latin9-iso"; break;
  5191. default: s = "transparent"; break;
  5192. }
  5193. if (strcmp(s,fcsinfo[csl].keyword) &&
  5194. strcmp(s,fcsinfo[csr].keyword))
  5195. printf(" (via %s)\n",s);
  5196. }
  5197. }
  5198. #endif /* MAC */
  5199. #endif /* OS2 */
  5200. #endif /* NOCSETS */
  5201. }
  5202. #ifndef NOLOCAL
  5203. #ifdef OS2
  5204. extern char htab[];
  5205. VOID
  5206. shotabs() {
  5207. int i,j,k,n;
  5208. printf("Tab Stops:\n\n");
  5209. for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
  5210. do {
  5211. printf("%c",htab[++i]=='T'?'T':'-');
  5212. } while (i % k && i < MAXTERMCOL);
  5213. printf("\n");
  5214. for ( ; j <= i; j++) {
  5215. switch ( j%10 ) {
  5216. case 1:
  5217. printf("%c",j == 1 ? '1' : '.');
  5218. break;
  5219. case 2:
  5220. case 3:
  5221. case 4:
  5222. case 5:
  5223. case 6:
  5224. case 7:
  5225. printf("%c",'.');
  5226. break;
  5227. case 8:
  5228. n = (j+2)/100;
  5229. if (n)
  5230. printf("%d",n);
  5231. else
  5232. printf("%c",'.');
  5233. break;
  5234. case 9:
  5235. n = (j+1)%100/10;
  5236. if (n)
  5237. printf("%d",n);
  5238. else if (j>90)
  5239. printf("0");
  5240. else
  5241. printf("%c",'.');
  5242. break;
  5243. case 0:
  5244. printf("0");
  5245. break;
  5246. }
  5247. }
  5248. printf("\n");
  5249. }
  5250. #ifdef COMMENT
  5251. for (i = 1; i <= 70; i++)
  5252. printf("%c",htab[i]=='T'?'T':'-');
  5253. printf("\n1.......10........20........30........40........50........60\
  5254. ........70\n\n");
  5255. for (; i <= 140; i++)
  5256. printf("%c",htab[i]=='T'?'T':'-');
  5257. printf("\n........80........90.......100.......110.......120.......130\
  5258. .......140\n\n");
  5259. for (; i <= 210; i++)
  5260. printf("%c",htab[i]=='T'?'T':'-');
  5261. printf("\n.......150.......160.......170.......180.......190.......200\
  5262. .......210\n\n");
  5263. for (; i <= 255; i++)
  5264. printf("%c",htab[i]=='T'?'T':'-');
  5265. printf("\n.......220.......230.......240.......250..255\n");
  5266. #endif
  5267. }
  5268. #endif /* OS2 */
  5269. #endif /* NOLOCAL */
  5270. #ifdef OS2MOUSE
  5271. VOID
  5272. shomou() {
  5273. int button, event, id, i;
  5274. char * name = "";
  5275. printf("Mouse settings:\n");
  5276. printf(" Button Count: %d\n",mousebuttoncount());
  5277. printf(" Active: %s\n\n",showoff(tt_mouse));
  5278. for (button = 0; button < MMBUTTONMAX; button++)
  5279. for (event = 0; event < MMEVENTSIZE; event++)
  5280. if (mousemap[button][event].type != error)
  5281. switch (mousemap[button][event].type) {
  5282. case key:
  5283. printf(" %s = Character: %c \\%d\n",
  5284. mousename(button,event),
  5285. mousemap[button][event].key.scancode,
  5286. mousemap[button][event].key.scancode );
  5287. break;
  5288. case kverb:
  5289. id = mousemap[button][event].kverb.id & ~(F_KVERB);
  5290. if (id != K_IGNORE) {
  5291. for (i = 0; i< nkverbs; i++)
  5292. if (id == kverbs[i].kwval) {
  5293. name = kverbs[i].kwd;
  5294. break;
  5295. }
  5296. printf(" %s = Kverb: \\K%s\n",
  5297. mousename(button,event),
  5298. name
  5299. );
  5300. }
  5301. break;
  5302. case macro:
  5303. printf(" %s = Macro: ",
  5304. mousename(button,event) );
  5305. shostrdef(mousemap[button][event].macro.string);
  5306. printf("\n");
  5307. break;
  5308. }
  5309. }
  5310. #endif /* OS2MOUSE */
  5311. #ifndef NOLOCAL
  5312. VOID
  5313. shotrm() {
  5314. char *s;
  5315. extern char * getiact();
  5316. extern int tt_print, adl_err;
  5317. #ifndef NOTRIGGER
  5318. extern char * tt_trigger[];
  5319. #endif /* NOTRIGGER */
  5320. #ifdef CKTIDLE
  5321. extern char * tt_idlesnd_str;
  5322. extern int tt_idlesnd_tmo;
  5323. extern int tt_idlelimit, tt_idleact;
  5324. #endif /* CKTIDLE */
  5325. #ifdef OS2
  5326. extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
  5327. decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
  5328. wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
  5329. int lines = 0;
  5330. #ifdef KUI
  5331. extern CKFLOAT tt_linespacing[];
  5332. extern tt_cursor_blink;
  5333. #endif /* KUI */
  5334. #ifdef PCFONTS
  5335. int i;
  5336. char *font;
  5337. if (IsOS2FullScreen()) { /* Determine the font name */
  5338. if (!os2LoadPCFonts()) {
  5339. for (i = 0; i < ntermfont; i++) {
  5340. if (tt_font == term_font[i].kwval) {
  5341. font = term_font[i].kwd;
  5342. break;
  5343. }
  5344. }
  5345. } else {
  5346. font = "(DLL not available)";
  5347. }
  5348. } else {
  5349. font = "(full screen only)";
  5350. }
  5351. #endif /* PCFONTS */
  5352. #ifdef KUI
  5353. char font[64] = "(unknown)";
  5354. if ( ntermfont > 0 ) {
  5355. int i;
  5356. for (i = 0; i < ntermfont; i++) {
  5357. if (tt_font == term_font[i].kwval) {
  5358. ckstrncpy(font,term_font[i].kwd,59);
  5359. ckstrncat(font," ",64);
  5360. ckstrncat(font,ckitoa(tt_font_size/2),64);
  5361. if ( tt_font_size % 2 )
  5362. ckstrncat(font,".5",64);
  5363. break;
  5364. }
  5365. }
  5366. }
  5367. #endif /* KUI */
  5368. printf("Terminal parameters:\n");
  5369. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5370. printf(" %19s: %1d%-12s %13s: %1d%-14s\n",
  5371. "Bytesize: Command",
  5372. (cmdmsk == 0377) ? 8 : 7,
  5373. " bits","Terminal",
  5374. (cmask == 0377) ? 8 : 7," bits");
  5375. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5376. printf(" %19s: %-13s","Type",
  5377. (tt_type >= 0 && tt_type <= max_tt) ?
  5378. tt_info[tt_type].x_name :
  5379. "unknown" );
  5380. if (tt_type >= 0 && tt_type <= max_tt)
  5381. if (strlen(tt_info[tt_type].x_id))
  5382. printf(" %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
  5383. printf("\n");
  5384. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5385. printf(" %19s: %-13s %13s: %-15s\n","Echo",
  5386. duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5387. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5388. printf(" %19s: %-13s %13s: %-15s\n","Newline-mode", showoff(tnlm),
  5389. "Cr-display",tt_crd ? "crlf" : "normal");
  5390. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5391. printf(" %19s: %-13s %13s: %-15s\n","Cursor",
  5392. #ifdef KUI
  5393. (tt_cursor == 2) ? (tt_cursor_blink ?
  5394. "full (*)" : "full (.)") :
  5395. (tt_cursor == 1) ? (tt_cursor_blink ?
  5396. "half (*)" : "half (.)") :
  5397. (tt_cursor_blink ? "underline (*)" : "underline (.)"),
  5398. #else /* KUI */
  5399. (tt_cursor == 2) ? "full" :
  5400. (tt_cursor == 1) ? "half" : "underline",
  5401. #endif /* KUI */
  5402. #ifdef CK_AUTODL
  5403. "autodownload",autodl == TAD_ON ?
  5404. (adl_err ? "on, error stop" : "on, error continue") :
  5405. autodl == TAD_ASK ?
  5406. (adl_err ? "ask, error stop" : "ask, error continue") :
  5407. "off"
  5408. #else /* CK_AUTODL */
  5409. "", ""
  5410. #endif /* CK_AUTODL */
  5411. );
  5412. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5413. printf(" %19s: %-13s %13s: %-15s\n","Arrow-keys",
  5414. tt_arrow ? "application" : "cursor",
  5415. "Keypad-mode", tt_keypad ? "application" : "numeric"
  5416. );
  5417. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5418. /* Just to make sure we are using current info */
  5419. updanswerbk();
  5420. /*
  5421. This line doesn't end with '\n' because the answerback string
  5422. is terminated with a newline
  5423. */
  5424. printf(" %19s: %-13s %13s: %-15s","Answerback",
  5425. showoff(tt_answer),"response",answerback);
  5426. switch (tt_bell) {
  5427. case XYB_NONE:
  5428. s = "none";
  5429. break;
  5430. case XYB_VIS:
  5431. s= "visible";
  5432. break;
  5433. case XYB_AUD | XYB_BEEP:
  5434. s="beep";
  5435. break;
  5436. case XYB_AUD | XYB_SYS:
  5437. s="system sounds";
  5438. break;
  5439. default:
  5440. s="(unknown)";
  5441. }
  5442. printf(" %19s: %-13s %13s: %-15s\n","Bell",s,
  5443. "Wrap",showoff(tt_wrap));
  5444. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5445. printf(" %19s: %-13s %13s: %-15s\n","Autopage",showoff(wy_autopage),
  5446. "Autoscroll",showoff(autoscroll));
  5447. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5448. printf(" %19s: %-13s %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
  5449. "ESC[0m color",colorreset?"default-color":"current-color");
  5450. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5451. printf(" %19s: %-13s %13s: %-15s\n",
  5452. "Erase color",user_erasemode?"default-color":"current-color",
  5453. "Screen mode",decscnm?"reverse":"normal");
  5454. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5455. printf(" %19s: %-13d %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
  5456. "Output-pacing",tt_pacing);
  5457. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5458. printf(" %19s: %-13d %13s: %s\n","Idle-timeout",tt_idlelimit,
  5459. "Idle-action", getiact());
  5460. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5461. printf(" %19s: %-13s %13s: %-15s\n","Send data",
  5462. showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
  5463. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5464. #ifndef NOTRIGGER
  5465. printf(" %19s: %-13s %13s: %d seconds\n","Auto-exit trigger",
  5466. tt_trigger[0],"Output pacing",tt_pacing );
  5467. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5468. #endif /* NOTRIGGER */
  5469. printf(" %19s: %-13s %13s: %-15d\n","Margin bell",
  5470. showoff(marginbell),"at column", marginbellcol);
  5471. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5472. switch (tt_modechg) {
  5473. case TVC_DIS: s = "disabled"; break;
  5474. case TVC_ENA: s = "enabled"; break;
  5475. case TVC_W95: s = "win95-restricted"; break;
  5476. default: s = "(unknown)";
  5477. }
  5478. printf(" %19s: %-13s %13s: %-15s\n","DG Unix mode",
  5479. showoff(dgunix),"Video change", s);
  5480. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5481. #ifdef CK_APC
  5482. if (apcstatus == APC_ON) s = "on";
  5483. else if (apcstatus == APC_OFF) s = "off";
  5484. else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
  5485. else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
  5486. else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
  5487. printf(" %19s: %-13s %13s: %-15s\n",
  5488. "APC", s,
  5489. #ifdef PCFONTS
  5490. "Font (VGA)",font
  5491. #else /* PCFONTS */
  5492. #ifdef KUI
  5493. "Font",font
  5494. #else
  5495. "Font","(not supported)"
  5496. #endif /* KUI */
  5497. #endif /* PCFONTS */
  5498. );
  5499. #endif /* CK_APC */
  5500. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5501. #ifdef CK_TTGWSIZ /* Console terminal screen size */
  5502. if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  5503. ttgwsiz(); /* Try to get latest size */
  5504. #endif /* CK_TTGWSIZ */
  5505. printf(" %19s: %-13d %13s: %-15d\n","Height",tt_rows[VTERM],
  5506. "Width",tt_cols[VTERM]);
  5507. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5508. #ifdef KUI
  5509. printf(" %19s: %-12f %14s: %-15d\n","Line spacing",tt_linespacing[VTERM],
  5510. "Display Height",VscrnGetDisplayHeight(VTERM));
  5511. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5512. #endif /* KUI */
  5513. printf(" %19s: %-13s %13s: %d lines\n","Roll-mode",
  5514. tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
  5515. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5516. if (updmode == tt_updmode)
  5517. if (updmode == TTU_FAST)
  5518. s = "fast (fast)";
  5519. else
  5520. s = "smooth (smooth)";
  5521. else
  5522. if (updmode == TTU_FAST)
  5523. s = "fast (smooth)";
  5524. else
  5525. s = "smooth (fast)";
  5526. printf(" %19s: %-13s %13s: %d ms\n","Screen-update: mode",s,
  5527. "interval",tt_update);
  5528. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5529. printf(" %19s: %-13s %13s: %-15s\n",
  5530. "Screen-optimization",showoff(tt_diff_upd),
  5531. "Status line",showoff(tt_status[VTERM]));
  5532. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5533. printf(" %19s: %-13s %13s: %-15s\n","Debug",
  5534. showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5535. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5536. /* Display colors (should become SHOW COLORS) */
  5537. {
  5538. USHORT row, col;
  5539. char * colors[16] = {
  5540. "black","blue","green","cyan","red","magenta","brown","lgray",
  5541. "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
  5542. };
  5543. printf("\n");
  5544. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5545. printf(" Color:");
  5546. #ifndef ONETERMUPD
  5547. GetCurPos(&row, &col);
  5548. WrtCharStrAtt("border", 6, row, 9, &colorborder );
  5549. WrtCharStrAtt("debug", 5, row, 17, &colordebug );
  5550. WrtCharStrAtt("helptext", 8, row, 25, &colorhelp );
  5551. WrtCharStrAtt("reverse", 7, row, 34, &colorreverse );
  5552. WrtCharStrAtt("select", 6, row, 42, &colorselect );
  5553. WrtCharStrAtt("status", 6, row, 50, &colorstatus );
  5554. WrtCharStrAtt("terminal", 8, row, 58, &colornormal );
  5555. WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
  5556. #endif /* ONETERMUPD */
  5557. row = VscrnGetCurPos(VCMD)->y+1;
  5558. VscrnWrtCharStrAtt(VCMD, "border", 6, row, 9, &colorborder );
  5559. VscrnWrtCharStrAtt(VCMD, "debug", 5, row, 17, &colordebug );
  5560. VscrnWrtCharStrAtt(VCMD, "helptext", 8, row, 25, &colorhelp );
  5561. VscrnWrtCharStrAtt(VCMD, "reverse", 7, row, 34, &colorreverse );
  5562. VscrnWrtCharStrAtt(VCMD, "select", 6, row, 42, &colorselect );
  5563. VscrnWrtCharStrAtt(VCMD, "status", 6, row, 50, &colorstatus );
  5564. VscrnWrtCharStrAtt(VCMD, "terminal", 8, row, 58, &colornormal );
  5565. VscrnWrtCharStrAtt(VCMD, "underline", 9, row, 67, &colorunderline );
  5566. printf("\n");
  5567. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5568. /* Foreground color names */
  5569. printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
  5570. "",
  5571. colors[colordebug&0x0F],
  5572. colors[colorhelp&0x0F],
  5573. colors[colorreverse&0x0F],
  5574. colors[colorselect&0x0F],
  5575. colors[colorstatus&0x0F],
  5576. colors[colornormal&0x0F],
  5577. colors[colorunderline&0x0F]);
  5578. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5579. /* Background color names */
  5580. printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
  5581. colors[colorborder],
  5582. colors[colordebug>>4],
  5583. colors[colorhelp>>4],
  5584. colors[colorreverse>>4],
  5585. colors[colorselect>>4],
  5586. colors[colorstatus>>4],
  5587. colors[colornormal>>4],
  5588. colors[colorunderline>>4] );
  5589. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5590. printf("\n");
  5591. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5592. printf(" Color:");
  5593. #ifndef ONETERMUPD
  5594. GetCurPos(&row, &col);
  5595. WrtCharStrAtt("graphic", 7, row, 9, &colorgraphic );
  5596. WrtCharStrAtt("command", 7, row, 17, &colorcmd );
  5597. WrtCharStrAtt("italic", 6, row, 26, &coloritalic );
  5598. #endif /* ONETERMUPD */
  5599. row = VscrnGetCurPos(VCMD)->y+1;
  5600. VscrnWrtCharStrAtt(VCMD, "graphic", 7, row, 9, &colorgraphic );
  5601. VscrnWrtCharStrAtt(VCMD, "command", 7, row, 17, &colorcmd );
  5602. VscrnWrtCharStrAtt(VCMD, "italic", 6, row, 26, &coloritalic );
  5603. printf("\n");
  5604. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5605. /* Foreground color names */
  5606. printf("%6s: %-8s%-8s%-8s\n","fore",
  5607. colors[colorgraphic&0x0F],
  5608. colors[colorcmd&0x0F],
  5609. colors[coloritalic&0x0F]);
  5610. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5611. /* Background color names */
  5612. printf("%6s: %-8s%-8s%-8s\n","back",
  5613. colors[colorgraphic>>4],
  5614. colors[colorcmd>>4],
  5615. colors[coloritalic>>4]);
  5616. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5617. }
  5618. printf("\n");
  5619. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5620. {
  5621. extern int trueblink, truedim, truereverse, trueunderline, trueitalic;
  5622. printf(
  5623. " Attribute: \
  5624. blink: %-3s dim: %-3s italic: %-3s reverse: %-3s underline: %-3s\n",
  5625. trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off",
  5626. truereverse?"on":"off", trueunderline?"on":"off");
  5627. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5628. }
  5629. {
  5630. extern vtattrib WPattrib;
  5631. printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
  5632. WPattrib.blinking?"blink ":"",
  5633. WPattrib.italic?"italic ":"",
  5634. WPattrib.reversed?"reverse ":"",
  5635. WPattrib.underlined?"underline ":"",
  5636. WPattrib.bold?"bold ":"",
  5637. WPattrib.dim?"dim ":"",
  5638. WPattrib.invisible?"invisible ":"");
  5639. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5640. }
  5641. printf("\n");
  5642. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5643. (VOID) shoesc(escape);
  5644. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5645. printf(" See SHOW CHARACTER-SETS for character-set info\n");
  5646. if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
  5647. #else /* OS2 */ /* Beginning of new non-OS2 version */
  5648. printf("\n");
  5649. printf("Terminal parameters:\n");
  5650. printf(" %19s: %1d%-12s %13s: %1d%-14s\n",
  5651. "Bytesize: Command",
  5652. (cmdmsk == 0377) ? 8 : 7,
  5653. " bits","Terminal",
  5654. (cmask == 0377) ? 8 : 7," bits");
  5655. s = getenv("TERM");
  5656. #ifdef XPRINT
  5657. printf(" %19s: %-13s %13s: %-15s\n",
  5658. "Type",
  5659. s ? s : "(unknown)",
  5660. "Print",
  5661. showoff(tt_print)
  5662. );
  5663. #else
  5664. printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
  5665. #endif /* XPRINT */
  5666. printf(" %19s: %-13s %13s: %-15s\n","Echo",
  5667. duplex ? "local" : "remote","Locking-shift",showoff(sosi));
  5668. printf(" %19s: %-13s %13s: %-15s\n","Newline-mode",
  5669. showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");
  5670. #ifdef CK_APC
  5671. if (apcstatus == APC_ON) s = "on";
  5672. else if (apcstatus == APC_OFF) s = "off";
  5673. else if (apcstatus == (APC_ON|APC_UNCH)) s = "unchecked";
  5674. else if (apcstatus == (APC_ON|APC_NOINP)) s = "no-input";
  5675. else if (apcstatus == (APC_ON|APC_UNCH|APC_NOINP))
  5676. s = "unchecked-no-input";
  5677. printf(" %19s: %-13s %13s: %-15s\n",
  5678. "APC", s,
  5679. #ifdef CK_AUTODL
  5680. "Autodownload", autodl ?
  5681. (adl_err ? "on, error stop" : "on, error continue") : "off"
  5682. #else
  5683. "",""
  5684. #endif /* CK_AUTODL */
  5685. );
  5686. #endif /* CK_APC */
  5687. #ifdef CK_TTGWSIZ /* Console terminal screen size */
  5688. ttgwsiz(); /* Try to get latest size */
  5689. printf(" %19s: %-13d %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
  5690. #endif /* CK_TTGWSIZ */
  5691. printf(" %19s: %-13s %13s: %-15s\n","Debug",
  5692. showoff(debses),"Session log", seslog? sesfil : "(none)" );
  5693. #ifdef CKTIDLE
  5694. printf(" %19s: %-13d %13s: %s\n","Idle-timeout",tt_idlelimit,
  5695. "Idle-action", getiact());
  5696. #endif /* CKTIDLE */
  5697. printf(" %19s: %-13s ","Lf-display", tt_lfd ? "crlf" : "normal");
  5698. #ifdef UNIX
  5699. #ifndef NOJC
  5700. printf("%13s: %-15s","Suspend", showoff(xsuspend));
  5701. #endif /* NOJC */
  5702. #endif /* UNIX */
  5703. printf("\n");
  5704. #ifndef NOTRIGGER
  5705. printf(" %19s: %-13s\n","Trigger",
  5706. tt_trigger[0] ? tt_trigger[0] : "(none)");
  5707. #endif /* NOTRIGGER */
  5708. printf("\n");
  5709. (VOID) shoesc(escape);
  5710. #ifndef NOCSETS
  5711. shotcs(tcsl,tcsr); /* Show terminal character sets */
  5712. #endif /* NOCSETS */
  5713. #endif /* OS2 */
  5714. }
  5715. VOID
  5716. shmdmlin() { /* Briefly show modem & line */
  5717. #ifndef NODIAL
  5718. #ifndef MINIDIAL
  5719. #ifdef OLDTBCODE
  5720. extern int tbmodel;
  5721. _PROTOTYP( char * gtbmodel, (void) );
  5722. #endif /* OLDTBCODE */
  5723. #endif /* MINIDIAL */
  5724. #endif /* NODIAL */
  5725. if (local)
  5726. #ifdef OS2
  5727. printf(" Port: %s, Modem type: ",ttname);
  5728. #else
  5729. printf(" Line: %s, Modem type: ",ttname);
  5730. #endif /* OS2 */
  5731. else
  5732. printf(
  5733. #ifdef OS2
  5734. " Communication device not yet selected with SET PORT\n Modem type: "
  5735. #else
  5736. " Communication device not yet selected with SET LINE\n Modem type: "
  5737. #endif /* OS2 */
  5738. );
  5739. #ifndef NODIAL
  5740. printf("%s",gmdmtyp());
  5741. #ifndef MINIDIAL
  5742. #ifdef OLDTBCODE
  5743. if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
  5744. #endif /* OLDTBCODE */
  5745. #endif /* MINIDIAL */
  5746. #else
  5747. printf("(disabled)");
  5748. #endif /* NODIAL */
  5749. }
  5750. #ifdef CK_TAPI
  5751. void
  5752. shotapi(int option) {
  5753. int rc=0,k ;
  5754. char *s=NULL;
  5755. LPDEVCFG lpDevCfg = NULL;
  5756. LPCOMMCONFIG lpCommConfig = NULL;
  5757. LPMODEMSETTINGS lpModemSettings = NULL;
  5758. DCB * lpDCB = NULL;
  5759. extern struct keytab * tapiloctab; /* Microsoft TAPI Locations */
  5760. extern int ntapiloc;
  5761. extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
  5762. extern int ntapiline;
  5763. extern int tttapi; /* TAPI in use */
  5764. extern int tapipass; /* TAPI Passthrough mode */
  5765. extern int tapiconv; /* TAPI Conversion mode */
  5766. extern int tapilights;
  5767. extern int tapipreterm;
  5768. extern int tapipostterm;
  5769. extern int tapimanual;
  5770. extern int tapiinactivity;
  5771. extern int tapibong;
  5772. extern int tapiusecfg;
  5773. extern char tapiloc[];
  5774. extern int tapilocid;
  5775. extern int TAPIAvail;
  5776. if (!TAPIAvail) {
  5777. printf("TAPI Support not enabled\r\n");
  5778. return;
  5779. }
  5780. switch (option) {
  5781. case 0:
  5782. printf("TAPI Settings:\n");
  5783. printf(" Line: %s\n",
  5784. tttapi ? ttname : "(none in use)");
  5785. cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
  5786. if (tapilocid == -1)
  5787. tapilocid = cktapiGetCurrentLocationID();
  5788. /* Find the current tapiloc entry */
  5789. /* and use it as the default. */
  5790. for (k = 0; k < ntapiloc; k++) {
  5791. if (tapiloctab[k].kwval == tapilocid)
  5792. break;
  5793. }
  5794. if (k >= 0 && k < ntapiloc)
  5795. s = tapiloctab[k].kwd;
  5796. else
  5797. s = "(unknown)";
  5798. printf(" Location: %s\n",s);
  5799. printf(" Modem-dialing: %s\n",tapipass?"off":"on");
  5800. printf(" Phone-number-conversions: %s\n",
  5801. tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
  5802. printf(" Modem-lights: %s %s\n",tapilights?"on ":"off",
  5803. tapipass?"(n/a)":"");
  5804. printf(" Predial-terminal: %s %s\n",tapipreterm?"on ":"off",
  5805. tapipass?"(n/a)":"");
  5806. printf(" Postdial-terminal: %s %s\n",tapipostterm?"on ":"off",
  5807. tapipass?"(n/a)":"");
  5808. printf(" Manual-dial: %s %s\n",tapimanual?"on ":"off",
  5809. tapipass?"(n/a)":"");
  5810. printf(" Inactivity-timeout: %d seconds %s\n",tapiinactivity,
  5811. tapipass?"(n/a)":"");
  5812. printf(" Wait-for-bong: %d seconds %s\n",tapibong,
  5813. tapipass?"(n/a)":"");
  5814. printf(" Use-windows-configuration: %s %s\n",
  5815. tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
  5816. printf("\n");
  5817. #ifdef BETATEST
  5818. if (tapipass) {
  5819. printf("K-95 uses the TAPI Line in an exclusive mode. Other applications\n");
  5820. printf("may open the device but may not place calls nor answer calls.\n");
  5821. printf("Dialing is performed using the K-95 dialing procedures. SET MODEM\n");
  5822. printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
  5823. printf("definition associated with the active TAPI LINE device.\n\n");
  5824. } else {
  5825. printf("K-95 uses the TAPI Line in a cooperative mode. Other applications\n");
  5826. printf("may open the device, place and answer calls. Dialing is performed\n");
  5827. printf("by TAPI. K-95 SET MODEM commands are not used.\n\n");
  5828. }
  5829. if (tapiconv == CK_ON ||
  5830. tapiconv == CK_AUTO && !tapipass) {
  5831. printf(
  5832. "Phone numbers are converted from canonical to dialable form by TAPI\n");
  5833. printf("using the dialing rules specified in the TAPI Dialing Properties\n");
  5834. printf("dialog.\n\n");
  5835. } else {
  5836. printf(
  5837. "Phone numbers are converted from canonical to dialable form by K-95\n");
  5838. printf(
  5839. "using the dialing rules specified with the SET DIAL commands. TAPI\n");
  5840. printf(
  5841. "Dialing Properties are imported automaticly upon startup and whenever\n");
  5842. printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
  5843. printf("is changed.\n\n");
  5844. }
  5845. #endif /* BETATEST */
  5846. if (tapipass) {
  5847. printf("Type SHOW MODEM to see MODEM configuration.\n");
  5848. if (tapiconv == CK_ON)
  5849. printf("Type SHOW DIAL to see DIAL-related items.\n");
  5850. } else {
  5851. if (tapiconv == CK_ON || tapiconv == CK_AUTO)
  5852. printf("Type SHOW DIAL to see DIAL-related items.\n");
  5853. }
  5854. break;
  5855. case 1:
  5856. cktapiDisplayTapiLocationInfo();
  5857. break;
  5858. case 2:
  5859. rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
  5860. &lpCommConfig,&lpDCB);
  5861. if (rc) {
  5862. cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
  5863. lpCommConfig,lpDCB);
  5864. } else {
  5865. printf("?Unable to retrieve Modem Settings\n");
  5866. }
  5867. break;
  5868. case 3: {
  5869. HANDLE hModem = GetModemHandleFromLine((HLINE)0);
  5870. if (hModem)
  5871. DisplayCommProperties(hModem);
  5872. else
  5873. printf("?Unable to retrieve a valid Modem Handle\n");
  5874. CloseHandle(hModem);
  5875. break;
  5876. }
  5877. }
  5878. printf("\n");
  5879. }
  5880. #endif /* CK_TAPI */
  5881. #endif /* NOLOCAL */
  5882. #ifdef PATTERNS
  5883. static VOID
  5884. shopat() {
  5885. extern char * binpatterns[], * txtpatterns[];
  5886. extern int patterns, filepeek;
  5887. char **p, *s;
  5888. int i, j, k, n, flag, width;
  5889. #ifdef CK_TTGWSIZ
  5890. ttgwsiz(); /* Try to get latest size */
  5891. #ifdef OS2
  5892. width = tt_cols[VCMD];
  5893. #else /* OS2 */
  5894. width = tt_cols;
  5895. #endif /* OS2 */
  5896. if (width < 1)
  5897. #endif /* CK_TTGWSIZ */
  5898. width = 80;
  5899. printf("\n");
  5900. printf(" Set file type: %s\n",gfmode(binary,1));
  5901. printf(" Set file patterns: %s", showooa(patterns));
  5902. #ifdef CK_LABELED
  5903. if (binary == XYFT_L)
  5904. printf(" (but SET FILE TYPE LABELED overrides)\n");
  5905. else
  5906. #endif /* CK_LABELED */
  5907. #ifdef VMS
  5908. if (binary == XYFT_I)
  5909. printf(" (but SET FILE TYPE IMAGE overrides)\n");
  5910. else
  5911. #endif /* VMS */
  5912. if (filepeek)
  5913. printf(" (but SET FILE SCAN ON overrides)\n");
  5914. else
  5915. printf("\n");
  5916. printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
  5917. for (k = 0; k < 2; k++) { /* For each kind of patter */
  5918. printf("\n");
  5919. if (k == 0) { /* binary... */
  5920. printf(" File binary-patterns: ");
  5921. p = binpatterns;
  5922. } else { /* text... */
  5923. printf(" File text-patterns: ");
  5924. p = txtpatterns;
  5925. }
  5926. if (!p[0]) {
  5927. printf("(none)\n");
  5928. } else {
  5929. printf("\n ");
  5930. n = 2;
  5931. for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
  5932. if (!p[i]) /* Done */
  5933. break;
  5934. s = p[i]; /* Look for embedded space */
  5935. for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
  5936. if (*s == SP)
  5937. flag = 3;
  5938. n += j + flag; /* Length of this line */
  5939. if (n >= width - 1) {
  5940. printf("\n ");
  5941. n = j+2;
  5942. }
  5943. printf(flag == 3 ? " {%s}" : " %s", p[i]);
  5944. }
  5945. if (n > 2)
  5946. printf("\n");
  5947. }
  5948. }
  5949. printf("\n");
  5950. }
  5951. #endif /* PATTERNS */
  5952. #ifndef NOSPL
  5953. static VOID
  5954. shooutput() {
  5955. printf(" Output pacing: %d (milliseconds)\n",pacing);
  5956. printf(" Output special-escapes: %s\n", showoff(outesc));
  5957. }
  5958. static VOID
  5959. shoinput() {
  5960. #ifdef CKFLOAT
  5961. extern char * inpscale;
  5962. #endif /* CKFLOAT */
  5963. #ifdef CK_AUTODL
  5964. printf(" Input autodownload: %s\n", showoff(inautodl));
  5965. #endif /* CK_AUTODL */
  5966. printf(" Input cancellation: %s\n", showoff(inintr));
  5967. printf(" Input case: %s\n", inpcas[cmdlvl] ?
  5968. "observe" : "ignore");
  5969. printf(" Input buffer-length: %d\n", inbufsize);
  5970. printf(" Input echo: %s\n", showoff(inecho));
  5971. printf(" Input silence: %d (seconds)\n", insilence);
  5972. #ifdef OS2
  5973. printf(" Input terminal: %s\n", showoff(interm));
  5974. #endif /* OS2 */
  5975. printf(" Input timeout: %s\n", intime[cmdlvl] ?
  5976. "quit" : "proceed");
  5977. #ifdef CKFLOAT
  5978. printf(" Input scale-factor: %s\n", inpscale ? inpscale : "1.0");
  5979. #endif /* CKFLOAT */
  5980. if (instatus < 0)
  5981. printf(" Last INPUT: -1 (INPUT command not yet given)\n");
  5982. else
  5983. printf(" Last INPUT: %d (%s)\n", instatus,i_text[instatus]);
  5984. }
  5985. #endif /* NOSPL */
  5986. #ifndef NOSPL
  5987. int
  5988. showarray() {
  5989. #ifdef COMMENT
  5990. char * p, * q, ** ap;
  5991. int i;
  5992. #endif /* COMMENT */
  5993. char *s; int x = 0, y;
  5994. int range[2];
  5995. if ((y = cmfld("Array name","",&s,NULL)) < 0)
  5996. if (y != -3)
  5997. return(y);
  5998. ckstrncpy(line,s,LINBUFSIZ);
  5999. s = line;
  6000. if ((y = cmcfm()) < 0)
  6001. return(y);
  6002. if (*s) {
  6003. char ** ap;
  6004. if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  6005. printf("?Bad array: %s\n",s);
  6006. return(-9);
  6007. }
  6008. ap = a_ptr[x];
  6009. if (!ap) {
  6010. printf("Array not declared: %s\n", s);
  6011. return(success = 1);
  6012. } else {
  6013. int i, n, max;
  6014. max = (range[1] > 0) ?
  6015. range[1] :
  6016. ((range[0] > 0) ? range[0] : a_dim[x]);
  6017. if (range[0] < 0)
  6018. range[0] = 0;
  6019. if (max > a_dim[x])
  6020. max = a_dim[x];
  6021. n = 1;
  6022. printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
  6023. if (a_link[x] > -1)
  6024. printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
  6025. printf("\n");
  6026. for (i = range[0]; i <= max; i++) {
  6027. if (ap[i]) {
  6028. printf("%3d. %s\n",i,ap[i]);
  6029. if (xaskmore) {
  6030. if (cmd_cols > 0) {
  6031. x = strlen(ap[i]) + 5;
  6032. y = (x % cmd_cols) ? 1 : 0;
  6033. n += (x / cmd_cols) + y;
  6034. } else {
  6035. n++;
  6036. }
  6037. if (n > (cmd_rows - 3)) {
  6038. if (!askmore())
  6039. break;
  6040. else
  6041. n = 0;
  6042. }
  6043. }
  6044. }
  6045. }
  6046. }
  6047. return(1);
  6048. }
  6049. /* All arrays - just show name and dimension */
  6050. for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
  6051. if (a_ptr[y]) {
  6052. if (x == 0) printf("Declared arrays:\n");
  6053. x = 1;
  6054. printf(" \\&%c[%d]",
  6055. (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
  6056. if (a_link[y] > -1)
  6057. printf(" => \\&%c[]",arrayitoa(a_link[y]));
  6058. printf("\n");
  6059. }
  6060. if (!x) printf(" No arrays declared\n");
  6061. }
  6062. return(1);
  6063. }
  6064. #endif /* NOSPL */
  6065. int
  6066. doshow(x) int x; {
  6067. int y, z, i; long zz;
  6068. extern int optlines;
  6069. char *s;
  6070. #ifdef OS2
  6071. extern int os2gks;
  6072. extern int tt_kb_mode;
  6073. #endif /* OS2 */
  6074. extern int srvcdmsg;
  6075. extern char * cdmsgstr, * ckcdpath;
  6076. char fnbuf[100];
  6077. #ifndef NOSETKEY
  6078. if (x == SHKEY) { /* SHOW KEY */
  6079. int c;
  6080. #ifdef OS2
  6081. if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
  6082. "one",xxstring)) < 0) return(x);
  6083. switch (tt_kb_mode) {
  6084. case KBM_EM:
  6085. s = "emacs";
  6086. break;
  6087. case KBM_HE:
  6088. s = "hebrew";
  6089. break;
  6090. case KBM_RU:
  6091. s = "russian";
  6092. break;
  6093. case KBM_EN:
  6094. default:
  6095. s = "default";
  6096. break;
  6097. }
  6098. if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
  6099. s,xxstring)) < 0) return(z);
  6100. if (z == SHKEYDEF)
  6101. z = -1;
  6102. #endif /* OS2 */
  6103. if ((y = cmcfm()) < 0) return(y);
  6104. #ifdef IKSD
  6105. if (inserver) {
  6106. printf("Sorry, command disabled.\r\n");
  6107. return(success = 0);
  6108. }
  6109. #endif /* IKSD */
  6110. #ifdef MAC
  6111. printf("Not implemented\n");
  6112. return(0);
  6113. #else /* Not MAC */
  6114. #ifdef OS2
  6115. if (x) {
  6116. con_event evt;
  6117. for (c = 0; c < KMSIZE; c++) {
  6118. evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
  6119. if (evt.type != error) {
  6120. shokeycode(c,z);
  6121. }
  6122. }
  6123. } else {
  6124. #endif /* OS2 */
  6125. printf(" Press key: ");
  6126. #ifdef UNIX
  6127. #ifdef NOSETBUF
  6128. fflush(stdout);
  6129. #endif /* NOSETBUF */
  6130. #endif /* UNIX */
  6131. conbin((char)escape); /* Put terminal in binary mode */
  6132. #ifdef OS2
  6133. os2gks = 0; /* Raw scancode processing */
  6134. #endif /* OS2 */
  6135. c = congks(0); /* Get character or scan code */
  6136. #ifdef OS2
  6137. os2gks = 1; /* Cooked scancode processing */
  6138. #endif /* OS2 */
  6139. concb((char)escape); /* Restore terminal to cbreak mode */
  6140. if (c < 0) { /* Check for error */
  6141. printf("?Error reading key\n");
  6142. return(0);
  6143. }
  6144. #ifndef OS2
  6145. /*
  6146. Do NOT mask when it can be a raw scan code, perhaps > 255
  6147. */
  6148. c &= cmdmsk; /* Apply command mask */
  6149. #endif /* OS2 */
  6150. printf("\n");
  6151. #ifdef OS2
  6152. shokeycode(c,z);
  6153. #else /* OS2 */
  6154. shokeycode(c);
  6155. #endif /* OS2 */
  6156. #ifdef OS2
  6157. }
  6158. #endif /* OS2 */
  6159. return(1);
  6160. #endif /* MAC */
  6161. }
  6162. #ifndef NOKVERBS
  6163. if (x == SHKVB) { /* SHOW KVERBS */
  6164. if ((y = cmcfm()) < 0) return(y);
  6165. #ifdef IKSD
  6166. if (inserver) {
  6167. printf("Sorry, command disabled.\r\n");
  6168. return(success = 0);
  6169. }
  6170. #endif /* IKSD */
  6171. printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
  6172. kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
  6173. printf("\n");
  6174. return(1);
  6175. }
  6176. #ifdef OS2
  6177. if (x == SHUDK) { /* SHOW UDKs */
  6178. extern void showudk(void);
  6179. if ((y = cmcfm()) < 0) return(y);
  6180. #ifdef IKSD
  6181. if (inserver) {
  6182. printf("Sorry, command disabled.\r\n");
  6183. return(success = 0);
  6184. }
  6185. #endif /* IKSD */
  6186. showudk();
  6187. return(1);
  6188. }
  6189. #endif /* OS2 */
  6190. #endif /* NOKVERBS */
  6191. #endif /* NOSETKEY */
  6192. #ifndef NOSPL
  6193. if (x == SHMAC) { /* SHOW MACRO */
  6194. struct FDB kw, fl, cm;
  6195. int i, k, n = 0, left, flag, confirmed = 0;
  6196. char * p, *q[64];
  6197. for (i = 0; i < nmac; i++) { /* copy the macro table */
  6198. mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
  6199. mackey[i].kwval = i; /* with value = pointer to macro tbl */
  6200. mackey[i].flgs = mactab[i].flgs;
  6201. }
  6202. p = line;
  6203. left = LINBUFSIZ;
  6204. while (!confirmed && n < 64) {
  6205. cmfdbi(&kw, /* First FDB - macro table */
  6206. _CMKEY, /* fcode */
  6207. "Macro name", /* hlpmsg */
  6208. "", /* default */
  6209. "", /* addtl string data */
  6210. nmac, /* addtl numeric data 1: tbl size */
  6211. 0, /* addtl numeric data 2: 4 = cmswi */
  6212. xxstring, /* Processing function */
  6213. mackey, /* Keyword table */
  6214. &fl /* Pointer to next FDB */
  6215. );
  6216. cmfdbi(&fl, /* 2nd FDB - something not in mactab */
  6217. _CMFLD, /* fcode */
  6218. "", /* hlpmsg */
  6219. "", /* default */
  6220. "", /* addtl string data */
  6221. 0, /* addtl numeric data 1 */
  6222. 0, /* addtl numeric data 2 */
  6223. xxstring,
  6224. NULL,
  6225. &cm
  6226. );
  6227. cmfdbi(&cm, /* 3rd FDB - Confirmation */
  6228. _CMCFM, /* fcode */
  6229. "", /* hlpmsg */
  6230. "", /* default */
  6231. "", /* addtl string data */
  6232. 0, /* addtl numeric data 1 */
  6233. 0, /* addtl numeric data 2 */
  6234. NULL,
  6235. NULL,
  6236. NULL
  6237. );
  6238. x = cmfdb(&kw); /* Parse something */
  6239. if (x < 0)
  6240. return(x);
  6241. s = atmbuf; /* What the user typed */
  6242. switch (cmresult.fcode) {
  6243. case _CMKEY: /* If it was a keyword */
  6244. y = mlook(mactab,atmbuf,nmac); /* get full name */
  6245. if (y > -1)
  6246. s = mactab[y].kwd; /* (fall thru on purpose...) */
  6247. case _CMFLD:
  6248. k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
  6249. left -= k;
  6250. if (left <= 0) {
  6251. *p = NUL;
  6252. break;
  6253. }
  6254. q[n++] = p; /* Point to this item */
  6255. p += k; /* Move buffer pointer past it */
  6256. break;
  6257. case _CMCFM: /* End of command */
  6258. confirmed++;
  6259. default:
  6260. break;
  6261. }
  6262. }
  6263. if (n == 0) {
  6264. printf("Macros:\n");
  6265. slc = 1;
  6266. for (y = 0; y < nmac; y++)
  6267. if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
  6268. return(1);
  6269. }
  6270. slc = 0;
  6271. for (i = 0; i < n; i++) {
  6272. flag = 0;
  6273. s = q[i];
  6274. if (!s) s = "";
  6275. if (!*s) continue;
  6276. if (iswild(s)) { /* Pattern match */
  6277. for (k = 0, x = 0; x < nmac; x++) {
  6278. if (ckmatch(s,mactab[x].kwd,0,1)) {
  6279. shomac(mactab[x].kwd,mactab[x].mval);
  6280. k++;
  6281. }
  6282. }
  6283. if (!k)
  6284. x = -1;
  6285. else
  6286. continue;
  6287. } else { /* Exact match */
  6288. x = mxlook(mactab,s,nmac);
  6289. flag = 1;
  6290. }
  6291. if (flag && x == -1)
  6292. x = mlook(mactab,s,nmac);
  6293. switch (x) {
  6294. case -3: /* Nothing to look up */
  6295. case -1: /* Not found */
  6296. printf("%s - (not defined)\n",s);
  6297. break;
  6298. case -2: /* Ambiguous, matches more than one */
  6299. printf("%s - ambiguous\n",s);
  6300. break;
  6301. default: /* Matches one exactly */
  6302. shomac(mactab[x].kwd,mactab[x].mval);
  6303. break;
  6304. }
  6305. }
  6306. return(1);
  6307. }
  6308. #endif /* NOSPL */
  6309. /*
  6310. Other SHOW commands only have two fields. Get command confirmation here,
  6311. then handle with big switch() statement.
  6312. */
  6313. #ifndef NOSPL
  6314. if (x != SHBUI && x != SHARR)
  6315. #endif /* NOSPL */
  6316. if (x == SHFUN) { /* For SHOW FUNCTIONS */
  6317. int y;
  6318. if ((y = cmtxt("Match string for function names","",&s,NULL)) < 0)
  6319. return(y);
  6320. fnbuf[0] = NUL;
  6321. if (!s) s = "";
  6322. if (*s) ckstrncpy(fnbuf,s,100);
  6323. } else {
  6324. if ((y = cmcfm()) < 0)
  6325. return(y);
  6326. }
  6327. #ifdef COMMENT
  6328. /* This restriction is too general. */
  6329. #ifdef IKSD
  6330. if (inserver &&
  6331. #ifdef CK_LOGIN
  6332. isguest
  6333. #else
  6334. 0
  6335. #endif /* CK_LOGIN */
  6336. ) {
  6337. printf("Sorry, command disabled.\r\n");
  6338. return(success = 0);
  6339. }
  6340. #endif /* IKSD */
  6341. #endif /* COMMENT */
  6342. switch (x) {
  6343. #ifdef ANYX25
  6344. #ifndef IBMX25
  6345. case SHPAD:
  6346. shopad(0);
  6347. break;
  6348. #endif /* IBMX25 */
  6349. #endif /* ANYX25 */
  6350. case SHNET:
  6351. #ifdef NOLOCAL
  6352. printf(" No network support in this version of C-Kermit.\n");
  6353. #else
  6354. #ifndef NETCONN
  6355. printf(" No network support in this version of C-Kermit.\n");
  6356. #else
  6357. shonet();
  6358. #endif /* NETCONN */
  6359. #endif /* NOLOCAL */
  6360. break;
  6361. case SHPAR:
  6362. shopar();
  6363. break;
  6364. #ifndef NOXFER
  6365. case SHATT:
  6366. shoatt();
  6367. break;
  6368. #endif /* NOXFER */
  6369. #ifndef NOSPL
  6370. case SHCOU:
  6371. printf(" %d\n",count[cmdlvl]);
  6372. break;
  6373. #endif /* NOSPL */
  6374. #ifndef NOSERVER
  6375. case SHSER: /* Show Server */
  6376. i = 0;
  6377. #ifndef NOFRILLS
  6378. printf("Function: Status:\n");
  6379. i++;
  6380. printf(" GET %s\n",nm[en_get]);
  6381. i++;
  6382. printf(" SEND %s\n",nm[en_sen]);
  6383. i++;
  6384. printf(" MAIL %s\n",nm[inserver ? 0 : en_mai]);
  6385. i++;
  6386. printf(" PRINT %s\n",nm[inserver ? 0 : en_pri]);
  6387. i++;
  6388. #ifndef NOSPL
  6389. printf(" REMOTE ASSIGN %s\n",nm[en_asg]);
  6390. i++;
  6391. #endif /* NOSPL */
  6392. printf(" REMOTE CD/CWD %s\n",nm[en_cwd]);
  6393. i++;
  6394. #ifdef ZCOPY
  6395. printf(" REMOTE COPY %s\n",nm[en_cpy]);
  6396. i++;
  6397. #endif /* ZCOPY */
  6398. printf(" REMOTE DELETE %s\n",nm[en_del]);
  6399. printf(" REMOTE DIRECTORY %s\n",nm[en_dir]);
  6400. printf(" REMOTE HOST %s\n",nm[inserver ? 0 : en_hos]);
  6401. i += 3;
  6402. #ifndef NOSPL
  6403. printf(" REMOTE QUERY %s\n",nm[en_que]);
  6404. i++;
  6405. #endif /* NOSPL */
  6406. printf(" REMOTE MKDIR %s\n",nm[en_mkd]);
  6407. printf(" REMOTE RMDIR %s\n",nm[en_rmd]);
  6408. printf(" REMOTE RENAME %s\n",nm[en_ren]);
  6409. printf(" REMOTE SET %s\n",nm[en_set]);
  6410. printf(" REMOTE SPACE %s\n",nm[en_spa]);
  6411. printf(" REMOTE TYPE %s\n",nm[en_typ]);
  6412. printf(" REMOTE WHO %s\n",nm[inserver ? 0 : en_who]);
  6413. printf(" BYE %s\n",nm[en_bye]);
  6414. printf(" FINISH %s\n",nm[en_fin]);
  6415. printf(" EXIT %s\n",nm[en_xit]);
  6416. printf(" ENABLE %s\n",nm[en_ena]);
  6417. i += 11;
  6418. #endif /* NOFRILLS */
  6419. if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6420. printf("Server timeout: %d\n",srvtim);
  6421. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6422. printf("Server idle-timeout: %d\n",srvidl);
  6423. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6424. printf("Server keepalive %s\n", showoff(srvping));
  6425. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6426. printf("Server cd-message %s\n", showoff(srvcdmsg));
  6427. if (srvcdmsg && cdmsgstr)
  6428. printf("Server cd-message %s\n", cdmsgstr);
  6429. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6430. printf("Server display: %s\n", showoff(srvdis));
  6431. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6432. printf("Server login: ");
  6433. if (!x_user) {
  6434. printf("(none)\n");
  6435. } else {
  6436. printf("\"%s\", \"%s\", \"%s\"\n",
  6437. x_user,
  6438. x_passwd ? x_passwd : "",
  6439. x_acct ? x_acct : ""
  6440. );
  6441. }
  6442. if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
  6443. printf("Server get-path: ");
  6444. if (ngetpath == 0) {
  6445. printf(" (none)\n");
  6446. } else {
  6447. printf("\n");
  6448. i += 3;
  6449. for (x = 0; x < ngetpath; x++) {
  6450. if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
  6451. if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6452. if (!askmore())
  6453. break;
  6454. else
  6455. i = 0;
  6456. }
  6457. }
  6458. }
  6459. break;
  6460. #endif /* NOSERVER */
  6461. case SHSTA: /* Status of last command */
  6462. printf(" %s\n", success ? "SUCCESS" : "FAILURE");
  6463. return(0); /* Don't change it */
  6464. case SHSTK: { /* Stack for MAC debugging */
  6465. #ifdef MAC
  6466. long sp;
  6467. sp = -1;
  6468. loadA0 ((char *)&sp); /* set destination address */
  6469. SPtoaA0(); /* move SP to destination */
  6470. printf("Stack at 0x%x\n", sp);
  6471. show_queue(); /* more debugging */
  6472. break;
  6473. #else
  6474. shostack();
  6475. #endif /* MAC */
  6476. break;
  6477. }
  6478. #ifndef NOLOCAL
  6479. #ifdef OS2
  6480. case SHTAB: /* SHOW TABS */
  6481. #ifdef IKSD
  6482. if (inserver) {
  6483. printf("Sorry, command disabled.\r\n");
  6484. return(success = 0);
  6485. }
  6486. #endif /* IKSD */
  6487. shotabs();
  6488. break;
  6489. #endif /* OS2 */
  6490. case SHTER: /* SHOW TERMINAL */
  6491. #ifdef IKSD
  6492. if (inserver) {
  6493. printf("Sorry, command disabled.\r\n");
  6494. return(success = 0);
  6495. }
  6496. #endif /* IKSD */
  6497. shotrm();
  6498. break;
  6499. #ifdef OS2
  6500. case SHVSCRN: /* SHOW Virtual Screen - for debug */
  6501. shovscrn();
  6502. break;
  6503. #endif /* OS2 */
  6504. #endif /* NOLOCAL */
  6505. #ifdef OS2MOUSE
  6506. case SHMOU: /* SHOW MOUSE */
  6507. #ifdef IKSD
  6508. if (inserver) {
  6509. printf("Sorry, command disabled.\r\n");
  6510. return(success = 0);
  6511. }
  6512. #endif /* IKSD */
  6513. shomou();
  6514. break;
  6515. #endif /* OS2MOUSE */
  6516. #ifndef NOFRILLS
  6517. case SHVER:
  6518. shover();
  6519. break;
  6520. #endif /* NOFRILLS */
  6521. #ifndef NOSPL
  6522. case SHBUI: /* Built-in variables */
  6523. line[0] = NUL;
  6524. if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
  6525. return(y);
  6526. ckstrncpy(line,s,LINBUFSIZ);
  6527. /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */
  6528. case SHFUN: /* or built-in functions */
  6529. #ifdef CK_TTGWSIZ
  6530. #ifdef OS2
  6531. if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
  6532. ttgwsiz();
  6533. #else /* OS2 */
  6534. if (ttgwsiz() > 0) { /* Get current screen size */
  6535. if (tt_rows > 0 && tt_cols > 0) {
  6536. cmd_rows = tt_rows;
  6537. cmd_cols = tt_cols;
  6538. }
  6539. }
  6540. #endif /* OS2 */
  6541. #endif /* CK_TTGWSIZ */
  6542. if (x == SHFUN) { /* Functions */
  6543. printf("\nThe following functions are available:\n\n");
  6544. kwdhelp(fnctab,nfuncs,(char *)fnbuf,"\\F","()",3,8);
  6545. printf("\n");
  6546. #ifndef NOHELP
  6547. printf(
  6548. "HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
  6549. );
  6550. #endif /* NOHELP */
  6551. break;
  6552. } else { /* Variables */
  6553. int j, flag = 0, havearg = 0;
  6554. struct stringarray * q = NULL;
  6555. char ** pp;
  6556. if (line[0]) { /* Have something to search for */
  6557. havearg = 1; /* Maybe a list of things */
  6558. q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0,0);
  6559. if (!q) break;
  6560. pp = q->a_head;
  6561. }
  6562. i = 0;
  6563. for (y = 0; y < nvars; y++) {
  6564. if ((vartab[y].flgs & CM_INV))
  6565. continue;
  6566. if (havearg) { /* If I have something to match */
  6567. char * s2;
  6568. for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
  6569. s2 = pp[j] ? pp[j] : "";
  6570. #ifdef COMMENT
  6571. /* This is not needed because it's what the 4 arg does in ckmatch() */
  6572. len = strlen(s2);
  6573. if (len > 0) {
  6574. if (s2[len-1] != '$') {/* To allow anchors */
  6575. ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
  6576. s2 = line;
  6577. }
  6578. }
  6579. #endif /* COMMENT */
  6580. if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
  6581. flag = 1; /* Matches */
  6582. break;
  6583. }
  6584. }
  6585. if (!flag) /* Doesn't match */
  6586. continue;
  6587. }
  6588. s = nvlook(vartab[y].kwd);
  6589. printf(" \\v(%s) = ",vartab[y].kwd);
  6590. if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
  6591. while (*s) /* Show control chars symbolically */
  6592. printf("\\{%d}",*s++);
  6593. printf("\n");
  6594. } else if (vartab[y].kwval == VN_IBUF || /* \v(input) */
  6595. vartab[y].kwval == VN_QUE || /* \v(query) */
  6596. #ifdef OS2
  6597. vartab[y].kwval == VN_SELCT || /* \v(select) */
  6598. #endif /* OS2 */
  6599. (vartab[y].kwval >= VN_M_AAA && /* modem ones */
  6600. vartab[y].kwval <= VN_M_ZZZ)
  6601. ) {
  6602. int r = 12; /* This one can wrap around */
  6603. char buf[10];
  6604. while (*s) {
  6605. if (isprint(*s)) {
  6606. buf[0] = *s;
  6607. buf[1] = NUL;
  6608. r++;
  6609. } else {
  6610. sprintf(buf,"\\{%d}",*s); /* SAFE */
  6611. r += (int) strlen(buf);
  6612. }
  6613. if (r >= cmd_cols - 1) {
  6614. printf("\n");
  6615. r = 0;
  6616. i++;
  6617. }
  6618. printf("%s",buf);
  6619. s++;
  6620. }
  6621. printf("\n");
  6622. } else
  6623. printf("%s\n",s);
  6624. if (++i > (cmd_rows - 3)) { /* More than a screenful... */
  6625. if ((y >= nvars - 1) || !askmore())
  6626. break;
  6627. else
  6628. i = 0;
  6629. }
  6630. }
  6631. }
  6632. break;
  6633. case SHVAR: /* Global variables */
  6634. x = 0; /* Variable count */
  6635. slc = 1; /* Screen line count for "more?" */
  6636. for (y = 33; y < GVARS; y++)
  6637. if (g_var[y]) {
  6638. if (x++ == 0) printf("Global variables:\n");
  6639. sprintf(line," \\%%%c",y); /* SAFE */
  6640. if (shomac(line,g_var[y]) < 0) break;
  6641. }
  6642. if (!x) printf(" No variables defined\n");
  6643. break;
  6644. case SHARG: { /* Args */
  6645. char * s, * s1, * s2, * tmpbufp;
  6646. int t;
  6647. if (maclvl > -1) {
  6648. printf("Macro arguments at level %d (\\v(argc) = %d):\n",
  6649. maclvl,
  6650. macargc[maclvl]
  6651. );
  6652. for (y = 0; y < macargc[maclvl]; y++) {
  6653. s1 = m_arg[maclvl][y];
  6654. if (!s1) s1 = "(NULL)";
  6655. s2 = m_xarg[maclvl][y];
  6656. if (!s2) s2 = "(NULL)";
  6657. #ifdef COMMENT
  6658. if (y < 10)
  6659. printf(" \\%%%d = %s\n",y,s1);
  6660. else
  6661. printf(" \\&_[%d] = %s\n",y,s2);
  6662. #else
  6663. printf(" \\&_[%d] = %s\n",y,s2);
  6664. #endif /* COMMENT */
  6665. }
  6666. } else {
  6667. printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
  6668. for (y = 0; y < topargc; y++) {
  6669. s1 = g_var[y + '0'];
  6670. if (!s1) s1 = "(NULL)";
  6671. s2 = toparg[y];
  6672. if (!s2) s2 = "(NULL)";
  6673. if (y < 10 && g_var[y])
  6674. printf(" \\%%%d = %s\n",y,s1);
  6675. if (toparg[y])
  6676. printf(" \\&_[%d] = %s\n",y,s2);
  6677. }
  6678. }
  6679. }
  6680. break;
  6681. case SHARR: /* Arrays */
  6682. return(showarray());
  6683. #endif /* NOSPL */
  6684. #ifndef NOXFER
  6685. case SHPRO: /* Protocol parameters */
  6686. shoparp();
  6687. printf("\n");
  6688. break;
  6689. #endif /* NOXFER */
  6690. #ifndef NOLOCAL
  6691. case SHCOM: /* Communication parameters */
  6692. printf("\n");
  6693. shoparc();
  6694. #ifdef OS2
  6695. {
  6696. int i;
  6697. char *s = "(unknown)";
  6698. for (i = 0; i < nprty; i++)
  6699. if (prtytab[i].kwval == priority) {
  6700. s = prtytab[i].kwd;
  6701. break;
  6702. }
  6703. printf(" Priority: %s\n", s );
  6704. }
  6705. #endif /* OS2 */
  6706. printf("\n");
  6707. #ifdef NETCONN
  6708. if (!network
  6709. #ifdef IKSD
  6710. && !inserver
  6711. #endif /* IKSD */
  6712. ) {
  6713. #endif /* NETCONN */
  6714. shomdm();
  6715. printf("\n");
  6716. #ifdef NETCONN
  6717. }
  6718. #endif /* NETCONN */
  6719. #ifndef NODIAL
  6720. #ifdef IKSD
  6721. if ( !inserver )
  6722. #endif /* IKSD */
  6723. {
  6724. printf("Type SHOW DIAL to see DIAL-related items.\n");
  6725. printf("Type SHOW MODEM to see modem-related items.\n");
  6726. #ifdef CK_TAPI
  6727. printf("Type SHOW TAPI to see TAPI-related items.\n");
  6728. #endif /* CK_TAPI */
  6729. printf("\n");
  6730. }
  6731. #endif /* NODIAL */
  6732. break;
  6733. #endif /* NOLOCAL */
  6734. case SHFIL: /* File parameters */
  6735. shofil();
  6736. /* printf("\n"); */ /* (out o' space) */
  6737. break;
  6738. #ifndef NOCSETS
  6739. case SHLNG: /* Languages */
  6740. shoparl();
  6741. break;
  6742. #endif /* NOCSETS */
  6743. #ifndef NOSPL
  6744. case SHSCR: /* Scripts */
  6745. printf(" Command quoting: %s\n", showoff(cmdgquo()));
  6746. printf(" Take echo: %s\n", showoff(techo));
  6747. printf(" Take error: %s\n", showoff(takerr[cmdlvl]));
  6748. printf(" Macro echo: %s\n", showoff(mecho));
  6749. printf(" Macro error: %s\n", showoff(merror[cmdlvl]));
  6750. printf(" Quiet: %s\n", showoff(quiet));
  6751. printf(" Variable evaluation: %s [\\%%x and \\&x[] variables]\n",
  6752. vareval ? "recursive" : "simple");
  6753. printf(" Function diagnostics: %s\n", showoff(fndiags));
  6754. printf(" Function error: %s\n", showoff(fnerror));
  6755. #ifdef CKLEARN
  6756. {
  6757. extern char * learnfile;
  6758. extern int learning;
  6759. if (learnfile) {
  6760. printf(" LEARN file: %s (%s)\n",
  6761. learnfile,
  6762. learning ? "ON" : "OFF"
  6763. );
  6764. } else
  6765. printf(" LEARN file: (none)\n");
  6766. }
  6767. #endif /* CKLEARN */
  6768. shoinput();
  6769. shooutput();
  6770. #ifndef NOSCRIPT
  6771. printf(" Script echo: %s\n", showoff(secho));
  6772. #endif /* NOSCRIPT */
  6773. printf(" Command buffer length: %d\n", CMDBL);
  6774. printf(" Atom buffer length: %d\n", ATMBL);
  6775. break;
  6776. #endif /* NOSPL */
  6777. #ifndef NOXMIT
  6778. case SHXMI:
  6779. printf("\n");
  6780. printf(" File type: %s\n",
  6781. binary ? "binary" : "text");
  6782. #ifndef NOCSETS
  6783. printf(" File character-set: %s\n",
  6784. fcsinfo[fcharset].keyword);
  6785. #ifdef OS2
  6786. if ( isunicode() ) {
  6787. printf(" Terminal Character (remote): %s\n",
  6788. tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  6789. tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  6790. printf(" Terminal Character (local): %s\n",
  6791. tcsl == TX_TRANSP ? "transparent" :
  6792. tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  6793. } else {
  6794. printf(" Terminal Character (remote): %s\n",
  6795. tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
  6796. tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
  6797. printf(" Terminal Character (local): %s\n",
  6798. tcsl == TX_TRANSP ? "transparent" :
  6799. tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
  6800. }
  6801. #else /* OS2 */
  6802. printf(" Terminal character-set (remote): %s\n",
  6803. fcsinfo[tcsr].keyword);
  6804. printf(" Terminal character-set (local): %s\n",
  6805. fcsinfo[tcsl].keyword);
  6806. #endif /* OS2 */
  6807. #endif /* NOCSETS */
  6808. printf(" Terminal bytesize: %d\n",
  6809. (cmask == 0xff) ? 8 : 7);
  6810. printf(" Terminal echo: %s\n",
  6811. duplex ? "local" : "remote");
  6812. printf(" Transmit EOF: ");
  6813. if (*xmitbuf == NUL) {
  6814. printf("(none)\n");
  6815. } else {
  6816. char *p;
  6817. p = xmitbuf;
  6818. while (*p) {
  6819. if (*p < SP)
  6820. printf("^%c",ctl(*p));
  6821. else
  6822. printf("%c",*p);
  6823. p++;
  6824. }
  6825. printf("\n");
  6826. }
  6827. if (xmitf)
  6828. printf(" Transmit Fill: %d\n", xmitf);
  6829. else
  6830. printf(" Transmit Fill: (none)\n");
  6831. printf(" Transmit Linefeed: %s\n",showoff(xmitl));
  6832. if (xmitp)
  6833. printf(" Transmit Prompt: %d (%s)\n",
  6834. xmitp,
  6835. chartostr(xmitp)
  6836. );
  6837. else
  6838. printf(" Transmit Prompt: (none)\n");
  6839. printf(" Transmit Echo: %s\n", showoff(xmitx));
  6840. printf(" Transmit Locking-Shift: %s\n", showoff(xmits));
  6841. printf(" Transmit Pause: %d (millisecond%s)\n",
  6842. xmitw,
  6843. (xmitw == 1) ? "" : "s"
  6844. );
  6845. printf(" Transmit Timeout: %d (second%s)\n",
  6846. xmitt,
  6847. (xmitt == 1) ? "" : "s"
  6848. );
  6849. printf("\n");
  6850. break;
  6851. #endif /* NOXMIT */
  6852. #ifndef NODIAL
  6853. case SHMOD: /* SHOW MODEM */
  6854. #ifdef IKSD
  6855. if (inserver) {
  6856. printf("Sorry, command disabled.\r\n");
  6857. return(success = 0);
  6858. }
  6859. #endif /* IKSD */
  6860. shomodem(); /* Show SET MODEM items */
  6861. break;
  6862. #endif /* NODIAL */
  6863. #ifndef MAC
  6864. case SHDFLT:
  6865. printf("%s\n",zgtdir());
  6866. break;
  6867. #endif /* MAC */
  6868. #ifndef NOLOCAL
  6869. case SHESC:
  6870. #ifdef IKSD
  6871. if (inserver) {
  6872. printf("Sorry, command disabled.\r\n");
  6873. return(success = 0);
  6874. }
  6875. #endif /* IKSD */
  6876. return(shoesc(escape));
  6877. #ifndef NODIAL
  6878. case SHDIA: /* SHOW DIAL */
  6879. #ifdef IKSD
  6880. if (inserver) {
  6881. printf("Sorry, command disabled.\r\n");
  6882. return(success = 0);
  6883. }
  6884. #endif /* IKSD */
  6885. shmdmlin();
  6886. printf(", speed: ");
  6887. if ((zz = ttgspd()) < 0) {
  6888. printf("unknown");
  6889. } else {
  6890. if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
  6891. }
  6892. if (carrier == CAR_OFF) s = "off";
  6893. else if (carrier == CAR_ON) s = "on";
  6894. else if (carrier == CAR_AUT) s = "auto";
  6895. else s = "unknown";
  6896. printf(", carrier: %s", s);
  6897. if (carrier == CAR_ON) {
  6898. if (cdtimo) printf(", timeout: %d sec", cdtimo);
  6899. else printf(", timeout: none");
  6900. }
  6901. printf("\n");
  6902. doshodial();
  6903. if (local
  6904. #ifdef NETCONN
  6905. && !network
  6906. #endif /* NETCONN */
  6907. ) {
  6908. printf("Type SHOW MODEM to see modem settings.\n");
  6909. #ifdef CK_TAPI
  6910. printf("Type SHOW TAPI to see TAPI-related items\n");
  6911. #endif /* CK_TAPI */
  6912. printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
  6913. }
  6914. break;
  6915. #endif /* NODIAL */
  6916. #endif /* NOLOCAL */
  6917. #ifndef NOXFER
  6918. #ifdef CK_LABELED
  6919. case SHLBL: /* Labeled file info */
  6920. sholbl();
  6921. break;
  6922. #endif /* CK_LABELED */
  6923. #endif /* NOXFER */
  6924. case SHCSE: /* Character sets */
  6925. #ifdef NOCSETS
  6926. printf(
  6927. " Character set translation is not supported in this version of C-Kermit\n");
  6928. #else
  6929. shocharset();
  6930. #ifndef NOXFER
  6931. printf("\n Unknown-Char-Set: %s\n",
  6932. unkcs ? "Keep" : "Discard");
  6933. #endif /* NOXFER */
  6934. #ifdef OS2
  6935. printf("\n");
  6936. #endif /* OS2 */
  6937. shotcs(tcsl,tcsr);
  6938. printf("\n");
  6939. #ifdef OS2
  6940. /* PC Code Page information */
  6941. {
  6942. char cpbuf[128];
  6943. int cplist[16], cps;
  6944. int activecp;
  6945. cps = os2getcplist(cplist, sizeof(cplist));
  6946. sprintf(cpbuf, /* SAFE */
  6947. "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
  6948. cps > 1 ? cplist[1] : 0,
  6949. cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
  6950. cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
  6951. cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
  6952. cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
  6953. cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
  6954. cps > 12 ? cplist[12] : 0
  6955. );
  6956. printf(" Code Pages:\n");
  6957. activecp = os2getcp();
  6958. if ( activecp ) {
  6959. printf(" Active: %d\n",activecp);
  6960. if (!isWin95())
  6961. printf(" Available: %s\n",cpbuf);
  6962. } else
  6963. printf(" Active: n/a\n");
  6964. printf("\n");
  6965. }
  6966. #endif /* OS2 */
  6967. #endif /* NOCSETS */
  6968. break;
  6969. case SHFEA: /* Features */
  6970. shofea();
  6971. break;
  6972. #ifdef CK_SPEED
  6973. case SHCTL: /* Control-Prefix table */
  6974. shoctl();
  6975. break;
  6976. #endif /* CK_SPEED */
  6977. case SHEXI: {
  6978. extern int exithangup, exitmsg;
  6979. printf("\n Exit warning %s\n", xitwarn ?
  6980. (xitwarn == 1 ? "on" : "always") : "off");
  6981. printf(" Exit message: %s\n", exitmsg ?
  6982. (exitmsg == 1 ? "on" : "stderr") : "off");
  6983. printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
  6984. printf(" Exit hangup: %s\n", showoff(exithangup));
  6985. printf(" Current exit status: %d\n\n", xitsta);
  6986. break;
  6987. }
  6988. case SHPRT: {
  6989. #ifdef PRINTSWI
  6990. extern int printtimo, printertype, noprinter;
  6991. extern char * printterm, * printsep;
  6992. extern int prncs;
  6993. #ifdef BPRINT
  6994. extern int printbidi;
  6995. #endif /* BPRINT */
  6996. #endif /* PRINTSWI */
  6997. #ifdef IKSD
  6998. if (inserver &&
  6999. #ifdef CK_LOGIN
  7000. isguest
  7001. #else /* CK_LOGIN */
  7002. 0
  7003. #endif /* CK_LOGIN */
  7004. ) {
  7005. printf("Sorry, command disabled.\r\n");
  7006. return(success = 0);
  7007. }
  7008. #endif /* IKSD */
  7009. #ifdef PRINTSWI
  7010. if (noprinter) {
  7011. printf("Printer: (none)\n\n");
  7012. break;
  7013. }
  7014. #endif /* PRINTSWI */
  7015. printf("Printer: %s%s\n",
  7016. printpipe ? "| " : "",
  7017. printername ? printername :
  7018. #ifdef OS2
  7019. "PRN"
  7020. #else
  7021. "(default)"
  7022. #endif /* OS2 */
  7023. );
  7024. #ifdef PRINTSWI
  7025. #ifdef BPRINT
  7026. if (printbidi) {
  7027. printf(" /BIDIRECTIONAL\n");
  7028. if (pportspeed > 0)
  7029. printf(" /SPEED:%ld\n",pportspeed);
  7030. printf(" /PARITY:%s\n",parnam((char)pportparity));
  7031. printf(" /FLOW:%s\n",
  7032. pportflow == FLO_NONE ? "NONE" :
  7033. (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
  7034. );
  7035. } else
  7036. printf(" /OUTPUT-ONLY\n");
  7037. #endif /* BPRINT */
  7038. switch (printertype) {
  7039. case PRT_NON: printf(" /NONE\n"); break;
  7040. case PRT_FIL: printf(" /FILE\n"); break;
  7041. case PRT_PIP: printf(" /PIPE\n"); break;
  7042. case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
  7043. case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
  7044. }
  7045. printf(" /TIMEOUT:%d\n",printtimo);
  7046. if (printterm) {
  7047. printf(" /END-OF-JOB-STRING:");
  7048. shostrdef(printterm);
  7049. printf("\n");
  7050. } else
  7051. printf(" /END-OF-JOB-STRING:(none)\n");
  7052. printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
  7053. printf(" /CHARACTER-SET: %s\n",txrinfo[prncs]->keywd);
  7054. #endif /* PRINTSWI */
  7055. printf("\n");
  7056. break;
  7057. }
  7058. case SHCMD: {
  7059. #ifdef DOUBLEQUOTING
  7060. extern int dblquo;
  7061. #endif /* DOUBLEQUOTING */
  7062. #ifdef CK_AUTODL
  7063. printf(" Command autodownload: %s\n",showoff(cmdadl));
  7064. #else
  7065. printf(" Command autodownload: (not available)\n");
  7066. #endif /* CK_AUTODL */
  7067. printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
  7068. printf(" Command error-display: %d\n", cmd_err);
  7069. #ifdef CK_RECALL
  7070. printf(" Command recall-buffer-size: %d\n",cm_recall);
  7071. #else
  7072. printf(" Command recall-buffer not available in this version\n");
  7073. #endif /* CK_RECALL */
  7074. #ifdef CK_RECALL
  7075. printf(" Command retry: %s\n",showoff(cm_retry));
  7076. #else
  7077. printf(" Command retry not available in this version\n");
  7078. #endif /* CK_RECALL */
  7079. printf(" Command interruption: %s\n", showoff(cmdint));
  7080. printf(" Command quoting: %s\n", showoff(cmdgquo()));
  7081. #ifdef DOUBLEQUOTING
  7082. printf(" Command doublequoting: %s\n", showoff(dblquo));
  7083. #endif /* DOUBLEQUOTING */
  7084. printf(" Command more-prompting: %s\n", showoff(xaskmore));
  7085. printf(" Command height: %d\n", cmd_rows);
  7086. printf(" Command width: %d\n", cmd_cols);
  7087. #ifndef IKSDONLY
  7088. #ifdef OS2
  7089. printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
  7090. #endif /* OS2 */
  7091. #endif /* IKSDONLY */
  7092. #ifdef LOCUS
  7093. printf(" Locus: %s",
  7094. autolocus ? (autolocus == 2 ? "ask" : "auto") :
  7095. (locus ? "local" : "remote"));
  7096. if (autolocus)
  7097. printf(" (%s)", locus ? "local" : "remote");
  7098. printf("\n");
  7099. #endif /* LOCUS */
  7100. printf(" Hints: %s\n", showoff(hints));
  7101. printf(" Quiet: %s\n", showoff(quiet));
  7102. printf(" Maximum command length: %d\n", CMDBL);
  7103. #ifndef NOSPL
  7104. {
  7105. char * s;
  7106. int k;
  7107. printf(" Maximum number of macros: %d\n", MAC_MAX);
  7108. printf(" Macros defined: %d\n", nmac);
  7109. printf(" Maximum macro depth: %d\n", MACLEVEL);
  7110. printf(" Maximum TAKE depth: %d\n", MAXTAKE);
  7111. s = "(not defined)";
  7112. k = mlook(mactab,"on_unknown_command",nmac);
  7113. if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
  7114. printf(" ON_UNKNOWN_COMMAND: %s\n",s);
  7115. }
  7116. #endif /* NOSPL */
  7117. #ifdef UNIX
  7118. #ifndef NOJC
  7119. printf(" Suspend: %s\n", showoff(xsuspend));
  7120. #endif /* NOJC */
  7121. #endif /* UNIX */
  7122. printf(" Access to external commands and programs%s allowed\n",
  7123. #ifndef NOPUSH
  7124. !nopush ? "" :
  7125. #endif /* NOPUSH */
  7126. " not");
  7127. break;
  7128. }
  7129. #ifndef NOSPL
  7130. case SHALRM:
  7131. if (ck_alarm)
  7132. printf("Alarm at %s %s\n",alrm_date,alrm_time);
  7133. else
  7134. printf("(no alarm set)\n");
  7135. break;
  7136. #endif /* NOSPL */
  7137. #ifndef NOMSEND
  7138. case SHSFL: {
  7139. extern struct filelist * filehead;
  7140. if (!filehead) {
  7141. printf("send-list is empty\n");
  7142. } else {
  7143. struct filelist * flp;
  7144. char * s;
  7145. flp = filehead;
  7146. while (flp) {
  7147. s = flp->fl_alias;
  7148. if (!s) s = "(none)";
  7149. printf("%s, mode: %s, alias: %s\n",
  7150. flp->fl_name,
  7151. gfmode(flp->fl_mode,0),
  7152. s
  7153. );
  7154. flp = flp->fl_next;
  7155. }
  7156. }
  7157. }
  7158. break;
  7159. #endif /* NOMSEND */
  7160. #ifdef CKXXCHAR
  7161. case SHDBL:
  7162. shodbl();
  7163. break;
  7164. #endif /* CKXXCHAR */
  7165. #ifndef NOPUSH
  7166. #ifndef NOFRILLS
  7167. case SHEDIT:
  7168. if (!editor[0]) {
  7169. s = getenv("EDITOR");
  7170. if (s) ckstrncpy(editor,s,CKMAXPATH);
  7171. }
  7172. printf("\n editor: %s\n", editor[0] ? editor : "(none)");
  7173. if (editor[0]) {
  7174. printf(" options: %s\n", editopts[0] ? editopts : "(none)");
  7175. printf(" file: %s\n", editfile[0] ? editfile : "(none)");
  7176. }
  7177. printf("\n");
  7178. break;
  7179. #ifdef BROWSER
  7180. case SHBROWSE:
  7181. if (!browser[0]) {
  7182. s = getenv("BROWSER");
  7183. if (s) ckstrncpy(browser,s,CKMAXPATH);
  7184. }
  7185. printf("\n browser: %s\n", browser[0] ? browser : "(none)");
  7186. if (browser[0]) {
  7187. printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
  7188. printf(" url: %s\n", browsurl[0] ? browsurl : "(none)");
  7189. }
  7190. printf("\n");
  7191. break;
  7192. #endif /* BROWSER */
  7193. #endif /* NOFRILLS */
  7194. #endif /* NOPUSH */
  7195. #ifndef NOLOCAL
  7196. #ifdef CK_TAPI
  7197. case SHTAPI: /* TAPI options */
  7198. #ifdef IKSD
  7199. if (inserver) {
  7200. printf("Sorry, command disabled.\r\n");
  7201. return(success = 0);
  7202. }
  7203. #endif /* IKSD */
  7204. shotapi(0);
  7205. break;
  7206. case SHTAPI_L: /* TAPI Locations */
  7207. #ifdef IKSD
  7208. if (inserver) {
  7209. printf("Sorry, command disabled.\r\n");
  7210. return(success = 0);
  7211. }
  7212. #endif /* IKSD */
  7213. shotapi(1);
  7214. break;
  7215. case SHTAPI_M: /* TAPI Modem */
  7216. #ifdef IKSD
  7217. if (inserver) {
  7218. printf("Sorry, command disabled.\r\n");
  7219. return(success = 0);
  7220. }
  7221. #endif /* IKSD */
  7222. shotapi(2);
  7223. break;
  7224. case SHTAPI_C: /* TAPI Comm */
  7225. #ifdef IKSD
  7226. if (inserver) {
  7227. printf("Sorry, command disabled.\r\n");
  7228. return(success = 0);
  7229. }
  7230. #endif /* IKSD */
  7231. shotapi(3);
  7232. break;
  7233. #endif /* CK_TAPI */
  7234. case SHTCP: /* SHOTCP */
  7235. printf("\n");
  7236. shotcp(0);
  7237. printf("\n");
  7238. break;
  7239. #ifdef TNCODE
  7240. case SHTEL: /* TELNET */
  7241. printf("\n");
  7242. shotel(0);
  7243. printf("\n");
  7244. break;
  7245. case SHTOPT: /* TELNET OPTIONS */
  7246. printf("\n");
  7247. shotopt(0);
  7248. printf("\n");
  7249. break;
  7250. #endif /* TNCODE */
  7251. case SHOTMPDIR: /* TEMPORARY DIRECTORY */
  7252. {
  7253. extern char * tempdir;
  7254. if (!tempdir) {
  7255. printf(" (none)\n");
  7256. } else if (!*tempdir) {
  7257. printf(" (none)\n");
  7258. } else {
  7259. printf(" %s\n", tempdir);
  7260. }
  7261. break;
  7262. }
  7263. #ifdef CK_TRIGGER
  7264. case SHTRIG: {
  7265. extern char * tt_trigger[], * triggerval;
  7266. int i;
  7267. if (!tt_trigger[0]) {
  7268. printf(" Triggers: (none)\n");
  7269. } else {
  7270. printf(" Triggers:\n");
  7271. for (i = 0; i < TRIGGERS; i++) {
  7272. if (!tt_trigger[i])
  7273. break;
  7274. printf(" \"%s\"\n",tt_trigger[i]);
  7275. }
  7276. printf(" Most recent trigger encountered: ");
  7277. if (triggerval)
  7278. printf("\"%s\"\n",triggerval);
  7279. else
  7280. printf("(none)\n");
  7281. }
  7282. break;
  7283. }
  7284. #endif /* CK_TRIGGER */
  7285. #endif /* NOLOCAL */
  7286. #ifndef NOSPL
  7287. case SHINP:
  7288. shoinput();
  7289. break;
  7290. #endif /* NOSPL */
  7291. case SHLOG: {
  7292. #ifndef MAC
  7293. #ifdef IKSD
  7294. if (inserver &&
  7295. #ifdef CK_LOGIN
  7296. isguest
  7297. #else /* CK_LOGIN */
  7298. 0
  7299. #endif /* CK_LOGIN */
  7300. ) {
  7301. printf("Sorry, command disabled.\r\n");
  7302. return(success = 0);
  7303. }
  7304. #endif /* IKSD */
  7305. #ifdef DEBUG
  7306. printf("\n Debug log: %s", deblog ? debfil : "(none)");
  7307. {
  7308. extern int debtim;
  7309. if (debtim) printf(" (timestamps)");
  7310. printf("\n");
  7311. }
  7312. #endif /* DEBUG */
  7313. #ifndef NOXFER
  7314. printf(" Packet log: %s\n", pktlog ? pktfil : "(none)");
  7315. #endif /* NOXFER */
  7316. #ifndef NOLOCAL
  7317. printf(" Session log: %s", seslog ? sesfil : "(none)");
  7318. {
  7319. extern int sessft, slogts, slognul;
  7320. switch (sessft) {
  7321. case XYFT_T: printf(" (text)"); break;
  7322. case XYFT_B: printf(" (binary)"); break;
  7323. case XYFT_D: printf(" (debug)"); break;
  7324. }
  7325. if (slogts) printf("(timestamped)");
  7326. if (slognul) printf("(null-padded)");
  7327. printf("\n");
  7328. }
  7329. #endif /* NOLOCAL */
  7330. #ifdef TLOG
  7331. printf(" Transaction log: %s (%s)\n",
  7332. (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
  7333. (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
  7334. );
  7335. #endif /* TLOG */
  7336. #ifdef CKLOGDIAL
  7337. printf(" Connection log: %s\n", dialog ? diafil : "(none)");
  7338. #endif /* CKLOGDIAL */
  7339. printf("\n");
  7340. #endif /* MAC */
  7341. break;
  7342. }
  7343. #ifndef NOSPL
  7344. case SHOUTP: /* OUTPUT */
  7345. shooutput();
  7346. break;
  7347. #endif /* NOSPL */
  7348. #ifdef PATTERNS
  7349. case SHOPAT: /* PATTERNS */
  7350. shopat();
  7351. break;
  7352. #endif /* PATTERNS */
  7353. #ifdef STREAMING
  7354. case SHOSTR: { /* STREAMING */
  7355. extern int streamrq, clearrq, cleared;
  7356. extern long tfcps;
  7357. debug(F101,"SHOW RELIABLE reliable","",reliable);
  7358. printf("\n Reliable: %s\n",showooa(reliable));
  7359. printf(" Clearchannel: %s\n",showooa(clearrq));
  7360. printf(" Streaming: %s\n\n",showooa(streamrq));
  7361. if ((!local && (streamrq == SET_ON)) ||
  7362. (streamrq == SET_AUTO && reliable))
  7363. printf(" Streaming will be done if requested.\n");
  7364. else if ((streamrq == SET_OFF) ||
  7365. ((streamrq == SET_AUTO) && !reliable))
  7366. printf(" Streaming will not be requested and will not be done.\n");
  7367. else if ((streamrq == SET_ON) ||
  7368. ((streamrq == SET_AUTO) && reliable))
  7369. printf(
  7370. " Streaming will be requested and will be done if the other Kermit agrees.\n");
  7371. printf(" Last transfer: %sstreaming%s, %ld cps.\n",
  7372. streamed > 0 ? "" : "no ",
  7373. cleared ? ", clearchannel" : "",
  7374. tfcps
  7375. );
  7376. printf("\n");
  7377. break;
  7378. }
  7379. #endif /* STREAMING */
  7380. case SHOIKS:
  7381. return(sho_iks());
  7382. break;
  7383. #ifdef CK_AUTHENTICATION
  7384. case SHOAUTH:
  7385. return(sho_auth(0));
  7386. #endif /* CK_AUTHENTICATION */
  7387. #ifndef NOFTP
  7388. case SHOFTP: {
  7389. #ifdef IKSD
  7390. if (inserver) {
  7391. printf("Sorry, command disabled.\r\n");
  7392. return(success = 0);
  7393. }
  7394. #endif /* IKSD */
  7395. #ifdef SYSFTP
  7396. {
  7397. extern char ftpapp[], ftpopts[];
  7398. printf(" ftp-client: %s\n", ftpapp[0] ? ftpapp : "(none)");
  7399. if (ftpapp[0])
  7400. printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
  7401. }
  7402. #else
  7403. #ifdef NEWFTP
  7404. shoftp(0);
  7405. #else
  7406. printf("(No FTP client included in this version of Kermit.)\n");
  7407. #endif /* NEWFTP */
  7408. #endif /* SYSFTP */
  7409. break;
  7410. }
  7411. #endif /* NOFTP */
  7412. #ifndef NOCMDL
  7413. case SHXOPT: {
  7414. #ifdef IKSDB
  7415. extern int dbenabled;
  7416. extern char * dbfile, * dbdir;
  7417. #endif /* IKSDB */
  7418. #ifdef CKWTMP
  7419. extern int ckxwtmp;
  7420. extern char * wtmpfile;
  7421. #endif /* CKWTMP */
  7422. #ifdef CK_LOGIN
  7423. extern int ckxanon, xferlog, logintimo;
  7424. extern char * xferfile;
  7425. #ifdef UNIX
  7426. extern int ckxpriv;
  7427. #endif /* UNIX */
  7428. #ifdef CK_PERMS
  7429. extern int ckxperms;
  7430. #endif /* CK_PERMS */
  7431. #endif /* CK_LOGIN */
  7432. extern char * bannerfile, * helpfile;
  7433. #ifdef IKSD
  7434. if (inserver &&
  7435. #ifdef CK_LOGIN
  7436. isguest
  7437. #else /* CK_LOGIN */
  7438. 0
  7439. #endif /* CK_LOGIN */
  7440. ) {
  7441. printf("Sorry, command disabled.\r\n");
  7442. return(success = 0);
  7443. }
  7444. #endif /* IKSD */
  7445. printf("\n");
  7446. if (!cmdint)
  7447. printf(" --nointerrupts\n");
  7448. printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
  7449. printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
  7450. printf(" --cdmessage:%d\n",srvcdmsg);
  7451. printf(" --helpfile:%d\n",helpfile);
  7452. if (inserver) {
  7453. printf("\n");
  7454. break;
  7455. }
  7456. #ifdef CKSYSLOG
  7457. #ifdef SYSLOGLEVEL
  7458. printf(" --syslog:%d (forced)\n",ckxsyslog);
  7459. #else
  7460. printf(" --syslog:%d\n",ckxsyslog);
  7461. #endif /* SYSLOGLEVEL */
  7462. #endif /* CKSYSLOG */
  7463. #ifdef CKWTMP
  7464. printf(" --wtmplog:%d\n",ckxwtmp);
  7465. printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
  7466. #endif /* CKWTMP */
  7467. #ifdef IKSD
  7468. #ifdef CK_LOGIN
  7469. printf(" --anonymous:%d\n",ckxanon);
  7470. #ifdef UNIX
  7471. printf(" --privid:%d\n",ckxpriv);
  7472. #endif /* UNIX */
  7473. #ifdef CK_PERMS
  7474. printf(" --permission:%04o\n",ckxperms);
  7475. #endif /* CK_PERMS */
  7476. printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
  7477. printf(" --userfile:%s\n",userfile ? userfile : "(null)");
  7478. printf(" --root:%s\n",anonroot ? anonroot : "(null)");
  7479. printf(" --xferlog=%d\n",xferlog);
  7480. printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
  7481. printf(" --timeout=%d\n",logintimo);
  7482. #endif /* CK_LOGIN */
  7483. #ifdef IKSDB
  7484. printf(" --database=%d\n",dbenabled);
  7485. printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
  7486. if (dbdir)
  7487. printf(" (db directory=[%s])\n",dbdir);
  7488. #endif /* IKSDB */
  7489. #ifdef IKSDCONF
  7490. printf(" IKSD conf=%s\n",iksdconf);
  7491. #endif /* IKSDCONF */
  7492. #endif /* IKSD */
  7493. printf("\n");
  7494. break;
  7495. }
  7496. #endif /* NOCMDL */
  7497. case SHCD: {
  7498. extern char * myhome;
  7499. s = getenv("CDPATH");
  7500. if (!s) s = "(none)";
  7501. printf("\n current directory: %s\n", zgtdir());
  7502. printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
  7503. printf(" cd home: %s\n", homepath());
  7504. printf(" cd path: %s\n", ckcdpath ? ckcdpath : s);
  7505. printf(" cd message: %s\n", showoff(srvcdmsg & 2));
  7506. printf(" server cd-message: %s\n", showoff(srvcdmsg & 1));
  7507. printf(" cd message file: %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
  7508. break;
  7509. }
  7510. #ifndef NOCSETS
  7511. case SHASSOC:
  7512. (VOID) showassoc();
  7513. break;
  7514. #endif /* NOCSETS */
  7515. #ifdef CKLOGDIAL
  7516. case SHCONNX:
  7517. #ifdef NEWFTP
  7518. if (ftpisconnected()) {
  7519. extern char cxlogbuf[];
  7520. dologshow(W_FTP | 1);
  7521. if (cxlogbuf[0])
  7522. dologshow(1);
  7523. } else {
  7524. #endif /* NEWFTP */
  7525. dologshow(1);
  7526. #ifdef NEWFTP
  7527. }
  7528. #endif /* NEWFTP */
  7529. break;
  7530. #endif /* CKLOGDIAL */
  7531. case SHOPTS:
  7532. optlines = 0;
  7533. #ifndef NOFRILLS
  7534. (VOID) showdelopts();
  7535. #endif /* NOFRILLS */
  7536. #ifdef DOMYDIR
  7537. (VOID) showdiropts();
  7538. #endif /* DOMYDIR */
  7539. #ifdef CKPURGE
  7540. (VOID) showpurgopts();
  7541. #endif /* CKPURGE */
  7542. (VOID) showtypopts();
  7543. break;
  7544. #ifndef NOLOCAL
  7545. case SHOFLO:
  7546. (VOID) shoflow();
  7547. break;
  7548. #endif /* NOLOCAL */
  7549. #ifndef NOXFER
  7550. case SHOXFER:
  7551. (VOID) shoxfer();
  7552. break;
  7553. #endif /* NOXFER */
  7554. #ifdef CK_RECALL
  7555. case SHHISTORY:
  7556. (VOID) cmhistory();
  7557. break;
  7558. #endif /* CK_RECALL */
  7559. #ifndef NOSEXP
  7560. #ifndef NOSPL
  7561. case SHSEXP:
  7562. (VOID) shosexp();
  7563. break;
  7564. #endif /* NOSPL */
  7565. #endif /* NOSEXP */
  7566. #ifdef ANYSSH
  7567. case SHOSSH:
  7568. (VOID) shossh();
  7569. break;
  7570. #endif /* ANYSSH */
  7571. #ifdef KUI
  7572. case SHOGUI:
  7573. (VOID) shogui();
  7574. break;
  7575. #endif /* KUI */
  7576. #ifndef NOFRILLS
  7577. #ifndef NORENAME
  7578. case SHOREN:
  7579. (VOID) shorename();
  7580. break;
  7581. #endif /* NORENAME */
  7582. #endif /* NOFRILLS */
  7583. case SHOLOC: {
  7584. #ifdef HAVE_LOCALE
  7585. char *s;
  7586. extern int nolocale;
  7587. printf("\n");
  7588. printf("Locale %s:\n", nolocale ? "disabled" : "enabled");
  7589. #ifdef COMMENT
  7590. s = setlocale(LC_ALL, NULL);
  7591. if (!s) s = "";
  7592. printf("LC_ALL=%s\n",s);
  7593. #endif /* COMMENT */
  7594. s = setlocale(LC_COLLATE, NULL);
  7595. if (!s) s = "";
  7596. printf(" LC_COLLATE=\"%s\"\n",s);
  7597. s = setlocale(LC_CTYPE, NULL);
  7598. if (!s) s = "";
  7599. printf(" LC_CTYPE=\"%s\"\n",s);
  7600. s = setlocale(LC_MONETARY, NULL);
  7601. if (!s) s = "";
  7602. printf(" LC_MONETARY=\"%s\"\n",s);
  7603. s = setlocale(LC_MESSAGES, NULL);
  7604. if (!s) s = "";
  7605. printf(" LC_MESSAGES=\"%s\"\n",s);
  7606. s = setlocale(LC_NUMERIC, NULL);
  7607. if (!s) s = "";
  7608. printf(" LC_NUMERIC=\"%s\"\n",s);
  7609. s = setlocale(LC_TIME, NULL);
  7610. if (!s) s = "";
  7611. printf(" LC_TIME=\"%s\"\n",s);
  7612. printf(" LANG=\"%s\"\n",getenv("LANG"));
  7613. printf("\n");
  7614. #else
  7615. printf("\n");
  7616. printf(" Locale support is not included in this version of Kermit\n");
  7617. printf("\n");
  7618. #endif /* HAVE_LOCALE */
  7619. break;
  7620. }
  7621. default:
  7622. printf("\nNothing to show...\n");
  7623. return(-2);
  7624. }
  7625. return(success = 1);
  7626. }
  7627. #ifndef NOXFER
  7628. int
  7629. shoatt() {
  7630. printf("Attributes: %s\n", showoff(atcapr));
  7631. if (!atcapr) return(0);
  7632. printf(" Blocksize: %s\n", showoff(atblki));
  7633. printf(" Date: %s\n", showoff(atdati));
  7634. printf(" Disposition: %s\n", showoff(atdisi));
  7635. printf(" Encoding (Character Set): %s\n", showoff(atenci));
  7636. printf(" Length: %s\n", showoff(atleni));
  7637. printf(" Type (text/binary): %s\n", showoff(attypi));
  7638. printf(" System ID: %s\n", showoff(atsidi));
  7639. printf(" System Info: %s\n", showoff(atsysi));
  7640. #ifdef CK_PERMS
  7641. printf(" Permissions In: %s\n", showoff(atlpri));
  7642. printf(" Permissions Out: %s\n", showoff(atlpro));
  7643. #endif /* CK_PERMS */
  7644. #ifdef STRATUS
  7645. printf(" Format: %s\n", showoff(atfrmi));
  7646. printf(" Creator: %s\n", showoff(atcrei));
  7647. printf(" Account: %s\n", showoff(atacti));
  7648. #endif /* STRATUS */
  7649. return(0);
  7650. }
  7651. #endif /* NOXFER */
  7652. #ifndef NOSPL
  7653. int /* SHOW MACROS */
  7654. shomac(s1, s2) char *s1, *s2; {
  7655. int x, n, pp;
  7656. pp = 0; /* Parenthesis counter */
  7657. debug(F110,"shomac s1",s1,0);
  7658. debug(F110,"shomac s2",s2,0);
  7659. #ifdef IKSD
  7660. if ( inserver &&
  7661. #ifdef IKSDCONF
  7662. iksdcf
  7663. #else /* IKSDCONF */
  7664. 1
  7665. #endif /* IKSDCONF */
  7666. ) {
  7667. if (!ckstrcmp("on_exit",s1,-1,0) ||
  7668. !ckstrcmp("on_logout",s1,-1,0))
  7669. return(0);
  7670. }
  7671. #endif /* IKSD */
  7672. if (!s1)
  7673. return(0);
  7674. else
  7675. printf("%s = ",s1); /* Print blank line and macro name */
  7676. n = (int)strlen(s1) + 4; /* Width of current line */
  7677. if (!s2) s2 = "(not defined)";
  7678. while ((x = *s2++)) { /* Loop thru definition */
  7679. if (x == '(') pp++; /* Treat commas within parens */
  7680. if (x == ')') pp--; /* as ordinary text */
  7681. if (pp < 0) pp = 0; /* Outside parens, */
  7682. if (x == ',' && pp == 0) { /* comma becomes comma-dash-NL. */
  7683. putchar(',');
  7684. putchar('-');
  7685. x = '\n';
  7686. }
  7687. if (inserver && (x == '\n')) /* Send CR before LF */
  7688. putchar(CR);
  7689. putchar((CHAR)x); /* Output the character */
  7690. if (x == '\n') { /* If it was a newline */
  7691. #ifdef UNIX
  7692. #ifdef NOSETBUF
  7693. fflush(stdout);
  7694. #endif /* NOSETBUF */
  7695. #endif /* UNIX */
  7696. putchar(' '); /* Indent the next line 1 space */
  7697. while(*s2 == ' ') s2++; /* skip past leading blanks */
  7698. n = 2; /* restart the character counter */
  7699. slc++; /* and increment the line counter. */
  7700. } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
  7701. putchar('-'); /* output a dash */
  7702. if (inserver)
  7703. putchar(CR); /* and a carriage return */
  7704. putchar(NL); /* and a newline */
  7705. #ifdef UNIX
  7706. #ifdef NOSETBUF
  7707. fflush(stdout);
  7708. #endif /* NOSETBUF */
  7709. #endif /* UNIX */
  7710. n = 1; /* and restart the char counter */
  7711. slc++; /* and increment the line counter */
  7712. }
  7713. if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
  7714. if (!askmore()) return(-1); /* ask if they want more. */
  7715. n = 1; /* They do, start a new line */
  7716. slc = 0; /* and restart line counter */
  7717. }
  7718. }
  7719. if (inserver)
  7720. putchar(CR);
  7721. putchar(NL); /* End of definition */
  7722. if (++slc > (cmd_rows - 3)) {
  7723. if (!askmore()) return(-1);
  7724. slc = 0;
  7725. }
  7726. return(0);
  7727. }
  7728. #endif /* NOSPL */
  7729. #endif /* NOSHOW */
  7730. int x_ifnum = 0; /* Flag for IF NUMERIC active */
  7731. #ifndef NOSPL
  7732. /* Evaluate an arithmetic expression. */
  7733. /* Code adapted from ev, by Howie Kaye of Columbia U & others. */
  7734. static int xerror = 0;
  7735. int divbyzero = 0;
  7736. static char *cp;
  7737. static CK_OFF_T tokval;
  7738. static char curtok;
  7739. static CK_OFF_T expval;
  7740. #define LONGBITS (8*sizeof (CK_OFF_T))
  7741. #define NUMBER 'N'
  7742. #define N_EOT 'E'
  7743. /*
  7744. Replacement for strchr() and index(), neither of which seem to be universal.
  7745. */
  7746. static char *
  7747. #ifdef CK_ANSIC
  7748. windex(char * s, char c)
  7749. #else
  7750. windex(s,c) char *s, c;
  7751. #endif /* CK_ANSIC */
  7752. /* windex */ {
  7753. while (*s != NUL && *s != c) s++;
  7754. if (*s == c) return(s); else return(NULL);
  7755. }
  7756. /*
  7757. g e t t o k
  7758. Returns the next token. If token is a NUMBER, sets tokval appropriately.
  7759. */
  7760. static char
  7761. gettok() {
  7762. char tbuf[80] /* ,*tp */ ; /* Buffer to accumulate number */
  7763. while (isspace(*cp)) /* Skip past leading spaces */
  7764. cp++;
  7765. debug(F110,"GETTOK",cp,0);
  7766. switch (*cp) {
  7767. case '$': /* ??? */
  7768. case '+': /* Add */
  7769. case '-': /* Subtract or Negate */
  7770. case '@': /* Greatest Common Divisor */
  7771. case '*': /* Multiply */
  7772. case '/': /* Divide */
  7773. case '%': /* Modulus */
  7774. case '<': /* Left shift */
  7775. case '>': /* Right shift */
  7776. case '&': /* And */
  7777. case '|': /* Or */
  7778. case '#': /* Exclusive Or */
  7779. case '~': /* Not */
  7780. case '^': /* Exponent */
  7781. case '!': /* Factorial */
  7782. case '(': /* Parens for grouping */
  7783. case ')': return(*cp++); /* operator, just return it */
  7784. case '\n':
  7785. case '\0': return(N_EOT); /* End of line, return that */
  7786. }
  7787. #ifdef COMMENT
  7788. /* This is the original code, which allows only integer numbers. */
  7789. if (isxdigit(*cp)) { /* Digit, must be a number */
  7790. int radix = 10; /* Default radix */
  7791. for (tp = tbuf; isxdigit(*cp); cp++)
  7792. *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
  7793. *tp = '\0'; /* End number */
  7794. switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
  7795. case 'h':
  7796. case 'x': radix = 16; cp++; break; /* if radix signifier... */
  7797. case 'o':
  7798. case 'q': radix = 8; cp++; break;
  7799. case 't': radix = 2; cp++; break;
  7800. }
  7801. for (tp = tbuf, tokval = 0; *tp != '\0'; tp++) {
  7802. int dig;
  7803. dig = *tp - '0'; /* Convert number */
  7804. if (dig > 10) dig -= 'a'-'0'-10;
  7805. if (dig >= radix) {
  7806. if (cmdlvl == 0 && !x_ifnum && !xerror)
  7807. printf("?Invalid digit '%c' in number\n",*tp);
  7808. xerror = 1;
  7809. return(NUMBER);
  7810. }
  7811. tokval = radix*tokval + dig;
  7812. }
  7813. return(NUMBER);
  7814. }
  7815. if (cmdlvl == 0 && !x_ifnum && !xerror)
  7816. printf("Invalid character '%c' in input\n",*cp);
  7817. xerror = 1;
  7818. cp++;
  7819. return(gettok());
  7820. #else
  7821. /* This code allows non-numbers to be treated as macro names */
  7822. {
  7823. int i, x;
  7824. char * s, * cp1;
  7825. cp1 = cp;
  7826. tp = tbuf;
  7827. for (i = 0; i < 80; i++) {
  7828. /* Look ahead to next break character */
  7829. /* pretty much anything that is not in the switch() above. */
  7830. if (isalpha(*cp) || isdigit(*cp) ||
  7831. *cp == '_' || *cp == ':' || *cp == '.' ||
  7832. *cp == '[' || *cp == ']' ||
  7833. *cp == '{' || *cp == '}'
  7834. )
  7835. tbuf[i] = *cp++;
  7836. else
  7837. break;
  7838. }
  7839. if (i >= 80) {
  7840. printf("Too long - \"%s\"\n", cp1);
  7841. xerror = 1;
  7842. cp++;
  7843. return(gettok());
  7844. }
  7845. if (xerror) return(NUMBER);
  7846. tbuf[i] = NUL;
  7847. s = tbuf;
  7848. if (!isdigit(tbuf[0])) {
  7849. char * s2 = NULL;
  7850. x = mxlook(mactab,tbuf,nmac);
  7851. debug(F111,"gettok mxlook",tbuf,x);
  7852. if (x < 0) {
  7853. if (cmdlvl == 0 && !x_ifnum && !xerror)
  7854. printf("Bad number - \"%s\"\n",tbuf);
  7855. xerror = 1;
  7856. cp++;
  7857. return(gettok());
  7858. }
  7859. s2 = mactab[x].mval;
  7860. if (!s2) s2 = "";
  7861. if (*s2) s = s2;
  7862. }
  7863. #ifdef CKFLOAT
  7864. x = isfloat(s,0);
  7865. #else
  7866. x = chknum(s);
  7867. #endif /* CKFLOAT */
  7868. if (x > 0) {
  7869. tokval = ckatofs(s);
  7870. } else {
  7871. if (cmdlvl == 0 && !x_ifnum && !xerror)
  7872. printf("Bad number - \"%s\"\n",tbuf);
  7873. xerror = 1;
  7874. cp++;
  7875. return(gettok());
  7876. }
  7877. return(NUMBER);
  7878. }
  7879. #endif /* COMMENT */
  7880. }
  7881. static CK_OFF_T
  7882. #ifdef CK_ANSIC
  7883. expon(CK_OFF_T x, CK_OFF_T y)
  7884. #else
  7885. expon(x,y) CK_OFF_T x,y;
  7886. #endif /* CK_ANSIC */
  7887. /* expon */ {
  7888. CK_OFF_T result = 1;
  7889. int sign = 1;
  7890. if (y < 0) return(0);
  7891. if (x < 0) {
  7892. x = -x;
  7893. if (y & 1) sign = -1;
  7894. }
  7895. while (y != 0) {
  7896. if (y & 1) result *= x;
  7897. y >>= 1;
  7898. if (y != 0) x *= x;
  7899. }
  7900. return(result * sign);
  7901. }
  7902. /*
  7903. * factor ::= simple | simple ^ factor
  7904. *
  7905. */
  7906. static VOID
  7907. factor() {
  7908. CK_OFF_T oldval;
  7909. simple();
  7910. if (curtok == '^') {
  7911. oldval = expval;
  7912. curtok = gettok();
  7913. factor();
  7914. expval = expon(oldval,expval);
  7915. }
  7916. }
  7917. /*
  7918. * termp ::= NULL | {*,/,%,&} factor termp
  7919. *
  7920. */
  7921. static VOID
  7922. termp() {
  7923. while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
  7924. CK_OFF_T oldval;
  7925. char op;
  7926. op = curtok;
  7927. curtok = gettok(); /* skip past operator */
  7928. oldval = expval;
  7929. factor();
  7930. switch(op) {
  7931. case '*': expval = oldval * expval; break;
  7932. case '/':
  7933. case '%':
  7934. if (expval == 0) {
  7935. if (!x_ifnum)
  7936. printf("?Divide by zero\n");
  7937. xerror = 1;
  7938. divbyzero = 1;
  7939. expval = -1;
  7940. } else
  7941. expval = (op == '/') ? (oldval / expval) : (oldval % expval);
  7942. break;
  7943. case '&':
  7944. expval = oldval & expval; break;
  7945. }
  7946. }
  7947. }
  7948. static CK_OFF_T
  7949. #ifdef CK_ANSIC
  7950. fact(CK_OFF_T x)
  7951. #else
  7952. fact(x) CK_OFF_T x;
  7953. #endif /* CK_ANSIC */
  7954. /* fact */ { /* factorial */
  7955. CK_OFF_T result = 1;
  7956. while (x > 1)
  7957. result *= x--;
  7958. return(result);
  7959. }
  7960. /*
  7961. * term ::= factor termp
  7962. *
  7963. */
  7964. static VOID
  7965. term() {
  7966. factor();
  7967. termp();
  7968. }
  7969. static CK_OFF_T
  7970. #ifdef CK_ANSIC
  7971. gcd(CK_OFF_T x, CK_OFF_T y)
  7972. #else
  7973. gcd(x,y) CK_OFF_T x,y;
  7974. #endif /* CK_ANSIC */
  7975. /* gcd */ { /* Greatest Common Divisor */
  7976. int nshift = 0;
  7977. if (x < 0) x = -x;
  7978. if (y < 0) y = -y; /* validate arguments */
  7979. if (x == 0 || y == 0) return(x + y); /* this is bogus */
  7980. while (!((x & 1) | (y & 1))) { /* get rid of powers of 2 */
  7981. nshift++;
  7982. x >>= 1;
  7983. y >>= 1;
  7984. }
  7985. while (x != 1 && y != 1 && x != 0 && y != 0) {
  7986. while (!(x & 1)) x >>= 1; /* eliminate unnecessary */
  7987. while (!(y & 1)) y >>= 1; /* powers of 2 */
  7988. if (x < y) { /* force x to be larger */
  7989. CK_OFF_T t;
  7990. t = x;
  7991. x = y;
  7992. y = t;
  7993. }
  7994. x -= y;
  7995. }
  7996. if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
  7997. else return((CK_OFF_T) 1 << nshift); /* else gcd is 1 */
  7998. }
  7999. /*
  8000. * exprp ::= NULL | {+,-,|,...} term exprp
  8001. *
  8002. */
  8003. static VOID
  8004. exprp() {
  8005. while (windex("+-|<>#@",curtok) != NULL) {
  8006. CK_OFF_T oldval;
  8007. char op;
  8008. op = curtok;
  8009. curtok = gettok(); /* skip past operator */
  8010. oldval = expval;
  8011. term();
  8012. switch(op) {
  8013. case '+' : expval = oldval + expval; break;
  8014. case '-' : expval = oldval - expval; break;
  8015. case '|' : expval = oldval | expval; break;
  8016. case '#' : expval = oldval ^ expval; break;
  8017. case '@' : expval = gcd(oldval,expval); break;
  8018. case '<' : expval = oldval << expval; break;
  8019. case '>' : expval = oldval >> expval; break;
  8020. }
  8021. }
  8022. }
  8023. /*
  8024. * expr ::= term exprp
  8025. *
  8026. */
  8027. static VOID
  8028. expr() {
  8029. term();
  8030. exprp();
  8031. }
  8032. static CK_OFF_T
  8033. xparse() {
  8034. curtok = gettok();
  8035. expr();
  8036. #ifdef COMMENT
  8037. if (curtok == '$') {
  8038. curtok = gettok();
  8039. if (curtok != NUMBER) {
  8040. if (cmdlvl == 0 && !x_ifnum)
  8041. printf("?Illegal radix\n");
  8042. xerror = 1;
  8043. return(0);
  8044. }
  8045. curtok = gettok();
  8046. }
  8047. #endif /* COMMENT */
  8048. if (curtok != N_EOT) {
  8049. if (cmdlvl == 0 && !x_ifnum && !xerror)
  8050. printf("?Extra characters after expression\n");
  8051. xerror = 1;
  8052. }
  8053. return(expval);
  8054. }
  8055. char * /* Silent front end for evala() */
  8056. evalx(s) char *s; {
  8057. char * p;
  8058. int t;
  8059. t = x_ifnum;
  8060. x_ifnum = 1;
  8061. p = evala(s);
  8062. x_ifnum = t;
  8063. return(p);
  8064. }
  8065. char *
  8066. evala(s) char *s; {
  8067. CK_OFF_T v; /* Numeric value */
  8068. if (!s) return("");
  8069. xerror = 0; /* Start out with no error */
  8070. divbyzero = 0;
  8071. cp = s; /* Make the argument global */
  8072. v = xparse(); /* Parse the string */
  8073. return(xerror ? "" : ckfstoa(v)); /* Return empty string on error */
  8074. }
  8075. /*
  8076. * simplest ::= NUMBER | ( expr )
  8077. *
  8078. */
  8079. static VOID
  8080. simplest() {
  8081. char * p;
  8082. p = cp;
  8083. if (curtok == NUMBER)
  8084. expval = tokval;
  8085. else if (curtok == '(') {
  8086. curtok = gettok(); /* skip over paren */
  8087. expr();
  8088. if (curtok != ')') {
  8089. if (cmdlvl == 0 && !x_ifnum && !xerror)
  8090. printf("?Missing right parenthesis\n");
  8091. xerror = 1;
  8092. }
  8093. debug(F110,"GETTOK SIMPLEST ()",p,0);
  8094. } else {
  8095. if (cmdlvl == 0 && !x_ifnum && !xerror)
  8096. printf("?Operator unexpected\n");
  8097. xerror = 1;
  8098. }
  8099. curtok = gettok();
  8100. }
  8101. /*
  8102. * simpler ::= simplest | simplest !
  8103. *
  8104. */
  8105. static VOID
  8106. simpler() {
  8107. simplest();
  8108. if (curtok == '!') {
  8109. curtok = gettok();
  8110. expval = fact(expval);
  8111. }
  8112. }
  8113. /*
  8114. * simple ::= {-,~,!} simpler | simpler
  8115. *
  8116. */
  8117. static VOID
  8118. simple() {
  8119. if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
  8120. int op = curtok;
  8121. curtok = gettok(); /* skip over - sign */
  8122. simpler(); /* parse the factor again */
  8123. if (op != '+')
  8124. expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
  8125. } else simpler();
  8126. }
  8127. /* D C L A R R A Y -- Declare an array */
  8128. /*
  8129. Call with:
  8130. char a = single character designator for the array, e.g. "a".
  8131. int n = size of array. -1 means to undeclare the array.
  8132. Returns:
  8133. 0 or greater on success, having created the requested array with
  8134. with n+1 elements, 0..n. If an array of the same name existed
  8135. previously, it is destroyed. The new array has all its elements
  8136. initialized to NULL pointers. When an array is successfully created,
  8137. the return value is its index (0 = 'a', 1 = 'b', and so on.)
  8138. -1 on failure (because 'a' out of range or malloc failure).
  8139. */
  8140. int
  8141. #ifdef CK_ANSIC
  8142. dclarray(char a, int n)
  8143. #else
  8144. dclarray(a,n) char a; int n;
  8145. #endif /* CK_ANSIC */
  8146. /* dclarray */ {
  8147. char c, **p; int i, n2, rc;
  8148. if (a > 63 && a < 91) a += 32; /* Convert letters to lowercase */
  8149. if (a < ARRAYBASE || a > 122) /* Verify name */
  8150. return(-1);
  8151. if (n < 0) /* Check arg */
  8152. return(-1);
  8153. if (n+1 < 0) /* MAXINT+1 wraps around */
  8154. return(-1);
  8155. c = a;
  8156. a -= ARRAYBASE; /* Convert name to number */
  8157. rc = a; /* Array index will be return code */
  8158. if ((p = a_ptr[a]) != NULL) { /* Delete old array of same name */
  8159. if (a_link[a] > -1) { /* Is it a link? */
  8160. if (n == 0) { /* If we're just deleting it */
  8161. a_ptr[a] = (char **) NULL; /* clear all the info. */
  8162. a_dim[a] = 0;
  8163. a_link[a] = -1;
  8164. return(0);
  8165. } /* Not deleting */
  8166. a = a_link[a]; /* Switch to linked-to array */
  8167. }
  8168. n2 = a_dim[a]; /* Real array */
  8169. for (i = 0; i <= n2; i++) { /* First delete its elements */
  8170. if (p[i]) {
  8171. free(p[i]);
  8172. p[i] = NULL;
  8173. }
  8174. }
  8175. free((char *)a_ptr[a]); /* Then the element list */
  8176. if (n == 0) { /* If undeclaring this array... */
  8177. for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
  8178. if (i != a && a_link[i] == a) { /* Find them */
  8179. a_ptr[i] = (char **) NULL; /* and remove them */
  8180. a_dim[i] = 0;
  8181. a_link[i] = -1;
  8182. }
  8183. }
  8184. }
  8185. a_ptr[a] = (char **) NULL; /* Remove pointer to element list */
  8186. a_dim[a] = 0; /* Set dimension at zero. */
  8187. a_link[a] = -1; /* Unset link word */
  8188. }
  8189. if (n < 0) /* If only undeclaring, */
  8190. return(0); /* we're done. */
  8191. p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
  8192. if (p == NULL) return(-1); /* Check */
  8193. a_ptr[a] = p; /* Save pointer to member list */
  8194. a_dim[a] = n; /* Save dimension */
  8195. for (i = 0; i <= n; i++) /* Initialize members to null */
  8196. p[i] = NULL;
  8197. for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  8198. if (i != a && a_link[i] == a) { /* Find and update them */
  8199. a_ptr[i] = p;
  8200. a_dim[i] = n;
  8201. }
  8202. }
  8203. return(rc);
  8204. }
  8205. /* X A R R A Y -- Convert array name to array index */
  8206. int
  8207. xarray(s) char * s; {
  8208. char buf[8];
  8209. int x;
  8210. char c;
  8211. if (!s) s = "";
  8212. debug(F110,"xarray",s,0);
  8213. if (!*s)
  8214. return(-1);
  8215. x = strlen(s);
  8216. buf[0] = NUL;
  8217. buf[1] = NUL;
  8218. buf[2] = s[0];
  8219. buf[3] = (x > 0) ? s[1] : NUL;
  8220. buf[4] = (x > 1) ? s[2] : NUL;
  8221. buf[5] = (x > 2) ? s[3] : NUL;
  8222. buf[6] = NUL;
  8223. debug(F110,"xarray buf[3]",&buf[3],0);
  8224. s = buf+2;
  8225. if (*s == '&') {
  8226. buf[1] = CMDQ;
  8227. s--;
  8228. } else if (*s != CMDQ) {
  8229. buf[0] = CMDQ;
  8230. buf[1] = '&';
  8231. s = buf;
  8232. }
  8233. debug(F110,"xarray s",s,0);
  8234. c = *(s+2);
  8235. if (isupper(c))
  8236. c = tolower(c);
  8237. if (c == '@')
  8238. c = 96;
  8239. x = (int)c - ARRAYBASE;
  8240. if (*(s+3) == '[')
  8241. *(s+3) = NUL;
  8242. if (x < 0) {
  8243. return(-1);
  8244. }
  8245. if (x > ('z' - ARRAYBASE)) {
  8246. debug(F101,"xarray x out of range","",x);
  8247. return(-1);
  8248. }
  8249. if (*(s+3)) {
  8250. debug(F110,"xarray syntax",s,0);
  8251. return(-1);
  8252. }
  8253. return(x);
  8254. }
  8255. /*
  8256. boundspair() -- parses blah[n:m]
  8257. For use with array segment specifiers and compact substring notation.
  8258. Ignores the "blah" part, gets the values of n and m, which can be
  8259. numbers, variables, or arithmetic expressions; anything that resolves
  8260. to a number.
  8261. Call with:
  8262. s - string to parse
  8263. sep - array of permissible bounds separator chars
  8264. lo - pointer to low-bound result (or -1)
  8265. hi - pointer to hi-bound result (or -1)
  8266. zz - pointer to separator char that was encountered (or NUL)
  8267. Returns:
  8268. -1 on failure
  8269. 0 on success
  8270. */
  8271. int
  8272. #ifdef CK_ANSIC
  8273. boundspair(char *s, char *sep, int *lo, int *hi, char *zz)
  8274. #else
  8275. boundspair(s,sep,lo,hi,zz) char *s, *sep, *zz; int *lo, *hi;
  8276. #endif /* CK_ANSIC */
  8277. {
  8278. int i, x, y, range[2], bc = 0;
  8279. char c = NUL, *s2 = NULL, buf[256], *p, *q, *r, *e[2], *tmp = NULL;
  8280. debug(F110,"boundspair s",s,0);
  8281. debug(F110,"boundspair sep",sep,0);
  8282. *lo = -1; /* Default bounds */
  8283. *hi = -1;
  8284. *zz = 0; /* Default bounds separator */
  8285. range[0] = -1; /* It's OK -- get contents */
  8286. range[1] = -1; /* of subscript brackets */
  8287. if (!s) s = "";
  8288. if (!*s)
  8289. return(-1);
  8290. makestr(&tmp,s); /* Make a pokeable copy */
  8291. p = tmp;
  8292. q = NULL;
  8293. r = NULL;
  8294. for (p = s; *p; p++) { /* Get the two elements */
  8295. if (*p == '[') {
  8296. bc++; /* Bracket counter */
  8297. if (bc == 1 && !q) q = p+1;
  8298. } else if (*p == ']') {
  8299. bc--;
  8300. if (bc == 0 && q) *p = NUL;
  8301. } else if (bc == 1) { /* If within brackers */
  8302. s2 = ckstrchr(sep,*p); /* Check for separator */
  8303. if (s2) {
  8304. debug(F000,"boundspair *s2","",*s2);
  8305. if (c) {
  8306. debug(F000,"boundspair","Too many separators",*s2);
  8307. makestr(&tmp,NULL);
  8308. return(-1);
  8309. }
  8310. c = *s2; /* Separator character */
  8311. *p = NUL;
  8312. r = p+1;
  8313. }
  8314. }
  8315. }
  8316. if (bc == 0 && !q) {
  8317. /* This allows such constructions as "show array a" */
  8318. debug(F110,"boundspair","no brackets",0);
  8319. makestr(&tmp,NULL);
  8320. return(0);
  8321. }
  8322. if (bc != 0 || !q) {
  8323. debug(F110,"boundspair","unbalanced or missing brackets",0);
  8324. makestr(&tmp,NULL);
  8325. return(-1);
  8326. }
  8327. if (!q) q = "";
  8328. if (!*q) q = "-1";
  8329. if (!r) r = "";
  8330. if (!*r) r = "-1";
  8331. e[0] = q;
  8332. e[1] = r;
  8333. debug(F000,"boundspair c","",c);
  8334. debug(F110,"boundspair q",q,0);
  8335. debug(F110,"boundspair r",r,0);
  8336. for (i = 0; i < 2 && e[i]; i++) {
  8337. y = 255; /* Expand variables, etc. */
  8338. s = buf;
  8339. zzstring(e[i],&s,&y);
  8340. s = evalx(buf); /* Evaluate it arithmetically */
  8341. if (s) if (*s)
  8342. ckstrncpy(buf,s,256);
  8343. if (!chknum(buf)) { /* Did we get a number? */
  8344. debug(F110,"boundspair element not numeric",buf,0);
  8345. makestr(&tmp,NULL); /* No, fail. */
  8346. return(-1);
  8347. }
  8348. range[i] = atoi(buf);
  8349. }
  8350. makestr(&tmp,NULL); /* Free temporary poked string */
  8351. *lo = range[0]; /* Return what we got */
  8352. *hi = range[1];
  8353. *zz = c;
  8354. debug(F101,"boundspair lo","",*lo);
  8355. debug(F101,"boundspair hi","",*hi);
  8356. return(0);
  8357. }
  8358. /* A R R A Y B O U N D S -- Parse array segment notation \&a[n:m] */
  8359. /*
  8360. Call with s = array reference, plus two pointers to ints.
  8361. Returns -1 on error, or array index, with the two ints set as follows:
  8362. \&a[] -1, -1
  8363. \&a[3] 3, -1
  8364. \&a[3:17] 3, 17
  8365. The array need not be declared -- this routine is just for parsing.
  8366. */
  8367. int
  8368. arraybounds(s,lo,hi) char * s; int * lo, * hi; {
  8369. int i, x, y, range[2];
  8370. char zz, buf[256], * p, * q;
  8371. char * tmp = NULL;
  8372. *lo = -1; /* Default bounds */
  8373. *hi = -1;
  8374. if (!s) s = ""; /* Defense de null args */
  8375. if (!*s)
  8376. return(-1);
  8377. x = xarray(s); /* Check basic structure */
  8378. debug(F111,"arraybounds xarray",s,x);
  8379. if (x < 0) /* Not OK, fail. */
  8380. return(-1);
  8381. y = boundspair(s,":",lo,hi,&zz);
  8382. debug(F111,"arraybounds boundspair",s,y);
  8383. debug(F101,"arraybounds lo","",*lo);
  8384. debug(F101,"arraybounds hi","",*hi);
  8385. if (y < 0) /* Get bounds */
  8386. return(-1);
  8387. return(x);
  8388. }
  8389. /* A R R A Y N A M -- Parse an array name */
  8390. /*
  8391. Call with pointer to string that starts with the array reference.
  8392. String may begin with either \& or just &.
  8393. On success,
  8394. Returns letter ID (always lowercase) in argument c,
  8395. which can also be accent grave (` = 96; '@' is converted to grave);
  8396. Dimension or subscript in argument n;
  8397. IMPORTANT: These arguments must be provided by the caller as addresses
  8398. of ints (not chars), for example:
  8399. char *s; int x, y;
  8400. arraynam(s,&x,&y);
  8401. On failure, returns a negative number, with args n and c set to zero.
  8402. */
  8403. int
  8404. arraynam(ss,c,n) char *ss; int *c; int *n; {
  8405. int i, y, pp, len;
  8406. char x;
  8407. char *s, *p, *sx, *vnp;
  8408. /* On stack to allow for recursive calls... */
  8409. char vnbuf[ARRAYREFLEN+1]; /* Entire array reference */
  8410. char ssbuf[ARRAYREFLEN+1]; /* Subscript in "plain text" */
  8411. char sxbuf[16]; /* Evaluated subscript */
  8412. *c = *n = 0; /* Initialize return values */
  8413. len = strlen(ss);
  8414. for (pp = 0,i = 0; i < len; i++) { /* Check length */
  8415. if (ss[i] == '[') {
  8416. pp++;
  8417. } else if (ss[i] == ']') {
  8418. if (--pp == 0)
  8419. break;
  8420. }
  8421. }
  8422. if (i > ARRAYREFLEN) {
  8423. printf("?Array reference too long - %s\n",ss);
  8424. return(-9);
  8425. }
  8426. ckstrncpy(vnbuf,ss,ARRAYREFLEN);
  8427. vnp = vnbuf;
  8428. if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
  8429. if (*vnp != '&') {
  8430. printf("?Not an array - %s\n",vnbuf);
  8431. return(-9);
  8432. }
  8433. x = *(vnp + 1); /* Fold case of array name */
  8434. /* We don't use isupper & tolower here on purpose because these */
  8435. /* would produce undesired effects with accented letters. */
  8436. if (x > 63 && x < 91) x = *(vnp + 1) = (char) (x + 32);
  8437. if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
  8438. if (msgflg) {
  8439. printf("?Invalid format for array name - %s\n",vnbuf);
  8440. return(-9);
  8441. } else
  8442. return(-2);
  8443. }
  8444. *c = x; /* Return the array name */
  8445. s = vnp+3; /* Get dimension */
  8446. p = ssbuf;
  8447. pp = 1; /* Bracket counter */
  8448. for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
  8449. if (*s == '[') pp++;
  8450. if (*s == ']' && --pp == 0) break;
  8451. *p++ = *s++;
  8452. }
  8453. if (*s != ']') {
  8454. printf("?No closing bracket on array dimension - %s\n",vnbuf);
  8455. return(-9);
  8456. }
  8457. p--; /* Trim whitespace from end */
  8458. while (*p == SP || *p == HT)
  8459. p--;
  8460. p++;
  8461. *p = NUL; /* Terminate subscript with null */
  8462. p = ssbuf; /* Point to beginning of subscript */
  8463. while (*p == SP || *p == HT) /* Trim whitespace from beginning */
  8464. p++;
  8465. sx = sxbuf; /* Where to put expanded subscript */
  8466. y = 16;
  8467. {
  8468. /* Even if VARIABLE-EVALUATION SIMPLE use RECURSIVE for subscripts */
  8469. /* NOTE: This is vulnerable to SIGINT and whatnot... */
  8470. int tmp = vareval; /* Save VARIABLE-EVALUATION setting */
  8471. vareval = 1; /* Force it to RECURSIVE */
  8472. zzstring(p,&sx,&y); /* Convert variables, etc. */
  8473. vareval = tmp; /* Restore VARIABLE-EVALUATION */
  8474. }
  8475. sx = sxbuf;
  8476. while (*sx == SP) sx++;
  8477. /* debug(F110,"arraynam sx","",sx); */
  8478. if (!*sx) { /* Empty brackets... */
  8479. *n = -17; /* (Secret code :-) */
  8480. return(-2);
  8481. }
  8482. p = evala(sx); /* Run it thru \fneval()... */
  8483. if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */
  8484. if (!chknum(sxbuf)) { /* Make sure it's all digits */
  8485. if (msgflg) {
  8486. printf("?Array dimension or subscript missing or not numeric\n");
  8487. return(-9);
  8488. } else
  8489. return(-2);
  8490. }
  8491. if ((y = atoi(sxbuf)) < 0) {
  8492. if (cmflgs == 0) printf("\n");
  8493. if (msgflg) {
  8494. printf("?Array dimension or subscript not positive or zero\n");
  8495. return(-9);
  8496. } else
  8497. return(-2);
  8498. }
  8499. *n = y; /* Return the subscript or dimension */
  8500. return(0);
  8501. }
  8502. /* chkarray returns 0 or greater if array exists, negative otherwise */
  8503. int
  8504. chkarray(a,i) int a, i; { /* Check if array is declared */
  8505. int x; /* and if subscript is in range */
  8506. if (a == 64) a = 96; /* Convert atsign to grave accent */
  8507. x = a - ARRAYBASE; /* Values must be in range 95-122 */
  8508. #ifdef COMMENT
  8509. if (x == 0 && maclvl < 0) /* Macro arg vector but no macro */
  8510. return(0);
  8511. #endif /* COMMENT */
  8512. if (x < 0 || x > 'z' - ARRAYBASE) /* Not in range */
  8513. return(-2);
  8514. if (a_ptr[x] == NULL) return(-1); /* Not declared */
  8515. if (i > a_dim[x]) return(-2); /* Declared but out of range. */
  8516. return(a_dim[x]); /* All ok, return dimension */
  8517. }
  8518. #ifdef COMMENT /* This isn't used. */
  8519. char *
  8520. arrayval(a,i) int a, i; { /* Return value of \&a[i] */
  8521. int x; char **p; /* (possibly NULL) */
  8522. if (a == 64) a = 96; /* Convert atsign to grave accent */
  8523. x = a - ARRAYBASE; /* Values must be in range 95-122 */
  8524. if (x < 0 || x > 27) return(NULL); /* Not in range */
  8525. if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
  8526. return(NULL);
  8527. if (i > a_dim[x]) /* Subscript out of range. */
  8528. return(NULL);
  8529. return(p[i]); /* All ok, return pointer to value. */
  8530. }
  8531. #endif /* COMMENT */
  8532. /*
  8533. pusharray() is called when an array name is included in a LOCAL statement.
  8534. It moves the pointers from the global definition to the stack, and removes
  8535. the global definition. Later, if the same array is declared in the local
  8536. context, it occupies the global definition in the normal way. But when
  8537. popclvl() is called, it replaces the global definition with the one saved
  8538. here. The "secret code" is used to indicate to popclv() that it should
  8539. remove the global array when popping through this level -- otherwise if a
  8540. local array were declared that had no counterpart at any higher level, it
  8541. would never be deleted. This allows Algol-like inheritance to work both
  8542. on the way down and on the way back up.
  8543. */
  8544. int
  8545. pusharray(x,z) int x, z; {
  8546. int y;
  8547. debug(F000,"pusharray x","",x);
  8548. debug(F101,"pusharray z","",z);
  8549. y = chkarray(x,z);
  8550. debug(F101,"pusharray y","",y);
  8551. x -= ARRAYBASE; /* Convert name letter to index. */
  8552. if (x < 0 || x > 27)
  8553. return(-1);
  8554. if (y < 0) {
  8555. aa_ptr[cmdlvl][x] = (char **) NULL;
  8556. aa_dim[cmdlvl][x] = -23; /* Secret code (see popclvl()) */
  8557. } else {
  8558. aa_ptr[cmdlvl][x] = a_ptr[x];
  8559. aa_dim[cmdlvl][x] = y;
  8560. }
  8561. a_ptr[x] = (char **) NULL;
  8562. a_dim[x] = 0;
  8563. return(0);
  8564. }
  8565. /* P A R S E V A R -- Parse a variable name or array reference. */
  8566. /*
  8567. Call with:
  8568. s = pointer to candidate variable name or array reference.
  8569. *c = address of integer in which to return variable ID.
  8570. *i = address of integer in which to return array subscript.
  8571. Returns:
  8572. -2: syntax error in variable name or array reference.
  8573. 1: successful parse of a simple variable, with ID in c.
  8574. 2: successful parse of an array reference, w/ID in c and subscript in i.
  8575. */
  8576. int
  8577. parsevar(s,c,i) char *s; int *c, *i; {
  8578. char *p;
  8579. int x,y,z;
  8580. p = s;
  8581. if (*s == CMDQ) s++; /* Point after backslash */
  8582. if (*s != '%' && *s != '&') { /* Make sure it's % or & */
  8583. printf("?Not a variable name - %s\n",p);
  8584. return(-9);
  8585. }
  8586. if ((int)strlen(s) < 2) {
  8587. printf("?Incomplete variable name - %s\n",p);
  8588. return(-9);
  8589. }
  8590. if (*s == '%' && *(s+2) != '\0') {
  8591. printf("?Only one character after '%%' in variable name, please\n");
  8592. return(-9);
  8593. }
  8594. if (*s == '&' && *(s+2) != '[') {
  8595. printf("?Array subscript expected - %s\n",p);
  8596. return(-9);
  8597. }
  8598. if (*s == '%') { /* Simple variable. */
  8599. y = *(s+1); /* Get variable ID letter/char */
  8600. if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
  8601. *c = y; /* Set the return values. */
  8602. *i = -1; /* No array subscript. */
  8603. return(1); /* Return 1 = simple variable */
  8604. }
  8605. if (*s == '&') { /* Array reference. */
  8606. y = arraynam(s,&x,&z); /* Go parse it. */
  8607. debug(F101,"parsevar arraynam","",y);
  8608. if ((y) < 0) {
  8609. if (y == -2)
  8610. return(pusharray(x,z));
  8611. if (y != -9)
  8612. printf("?Invalid array reference - %s\n",p);
  8613. return(-9);
  8614. }
  8615. if (chkarray(x,z) < 0) { /* Check if declared, etc. */
  8616. printf("?Array not declared or subscript out of range\n");
  8617. return(-9);
  8618. }
  8619. *c = x; /* Return array letter */
  8620. *i = z; /* and subscript. */
  8621. return(2);
  8622. }
  8623. return(-2); /* None of the above. */
  8624. }
  8625. #define VALN 32
  8626. /* Get the numeric value of a variable */
  8627. /*
  8628. Call with pointer to variable name, pointer to int for return value.
  8629. Returns:
  8630. 0 on success with second arg containing the value.
  8631. -1 on failure (bad variable syntax, variable not defined or not numeric).
  8632. */
  8633. int
  8634. varval(s,v) char *s; CK_OFF_T *v; {
  8635. char valbuf[VALN+1]; /* s is pointer to variable name */
  8636. char name[256];
  8637. char *p;
  8638. int y;
  8639. if (*s != CMDQ) { /* Handle macro names too */
  8640. ckmakmsg(name,256,"\\m(",s,")",NULL);
  8641. s = name;
  8642. }
  8643. p = valbuf; /* Expand variable into valbuf. */
  8644. y = VALN;
  8645. if (zzstring(s,&p,&y) < 0) return(-1);
  8646. p = valbuf; /* Make sure value is numeric */
  8647. if (!*p) { /* Be nice -- let an undefined */
  8648. valbuf[0] = '0'; /* variable be treated as 0. */
  8649. valbuf[1] = NUL;
  8650. }
  8651. if (chknum(p)) { /* Convert numeric string to int */
  8652. *v = ckatofs(p); /* OK */
  8653. } else { /* Not OK */
  8654. p = evala(p); /* Maybe it's an expression */
  8655. if (!chknum(p)) /* Did it evaluate? */
  8656. return(-1); /* No, failure. */
  8657. else /* Yes, */
  8658. *v = ckatofs(p); /* success */
  8659. }
  8660. return(0);
  8661. }
  8662. /* Increment or decrement a variable */
  8663. /* Returns -1 on failure, 0 on success */
  8664. int
  8665. incvar(s,x,z) char *s; CK_OFF_T x; int z; { /* Increment a numeric variable */
  8666. CK_OFF_T n; /* s is pointer to variable name */
  8667. /* x is amount to increment by */
  8668. /* z != 0 means add */
  8669. /* z = 0 means subtract */
  8670. if (varval(s,&n) < 0) /* Convert numeric string to int */
  8671. return(-1);
  8672. if (z) /* Increment it by the given amount */
  8673. n += x;
  8674. else /* or decrement as requested. */
  8675. n -= x;
  8676. addmac(s,ckfstoa(n)); /* Replace old variable */
  8677. return(0);
  8678. }
  8679. /* D O D O -- Do a macro */
  8680. /*
  8681. Call with x = macro table index, s = pointer to arguments.
  8682. Returns 0 on failure, 1 on success.
  8683. */
  8684. int
  8685. dodo(x,s,flags) int x; char *s; int flags; {
  8686. int y;
  8687. extern int tra_asg, tra_cmd; int tra_tmp; /* For TRACE */
  8688. #ifndef NOLOCAL
  8689. #ifdef OS2
  8690. extern int term_io;
  8691. int term_io_sav = term_io;
  8692. #endif /* OS2 */
  8693. #endif /* NOLOCAL */
  8694. if (x < 0) /* It can happen! */
  8695. return(-1);
  8696. tra_tmp = tra_asg;
  8697. if (++maclvl >= MACLEVEL) { /* Make sure we have storage */
  8698. debug(F101,"dodo maclvl too deep","",maclvl);
  8699. --maclvl;
  8700. printf("Macros nested too deeply\n");
  8701. return(0);
  8702. }
  8703. macp[maclvl] = mactab[x].mval; /* Point to the macro body */
  8704. macx[maclvl] = mactab[x].mval; /* Remember where the beginning is */
  8705. #ifdef COMMENT
  8706. makestr(&(m_line[maclvl]),s); /* Entire arg string for "\%*" */
  8707. #endif /* COMMENT */
  8708. cmdlvl++; /* Entering a new command level */
  8709. if (cmdlvl >= CMDSTKL) { /* Too many macros + TAKE files? */
  8710. debug(F101,"dodo cmdlvl too deep","",cmdlvl);
  8711. cmdlvl--;
  8712. printf("?TAKE files and DO commands nested too deeply\n");
  8713. return(0);
  8714. }
  8715. #ifdef DEBUG
  8716. if (deblog) {
  8717. debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
  8718. debug(F010,"CMD ->",s,0);
  8719. }
  8720. #endif /* DEBUG */
  8721. #ifdef VMS
  8722. conres(); /* So Ctrl-C, etc, will work. */
  8723. #endif /* VMS */
  8724. #ifndef NOLOCAL
  8725. #ifdef OS2
  8726. term_io = 0; /* Disable terminal emulator I/O */
  8727. #endif /* OS2 */
  8728. #endif /* NOLOCAL */
  8729. ifcmd[cmdlvl] = 0;
  8730. iftest[cmdlvl] = 0;
  8731. count[cmdlvl] = count[cmdlvl-1]; /* Inherit COUNT from previous level */
  8732. intime[cmdlvl] = intime[cmdlvl-1]; /* Inherit previous INPUT TIMEOUT */
  8733. inpcas[cmdlvl] = inpcas[cmdlvl-1]; /* and INPUT CASE */
  8734. takerr[cmdlvl] = takerr[cmdlvl-1]; /* and TAKE ERROR */
  8735. merror[cmdlvl] = merror[cmdlvl-1]; /* and MACRO ERROR */
  8736. xquiet[cmdlvl] = quiet;
  8737. xvarev[cmdlvl] = vareval;
  8738. xcmdsrc = CMD_MD;
  8739. cmdstk[cmdlvl].src = CMD_MD; /* Say we're in a macro */
  8740. cmdstk[cmdlvl].lvl = maclvl; /* and remember the macro level */
  8741. cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */
  8742. /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */
  8743. if (!(flags & CF_IMAC) && mrval[maclvl]) {
  8744. free(mrval[maclvl]);
  8745. mrval[maclvl] = NULL;
  8746. }
  8747. /* Clear old %0..%9 arguments */
  8748. addmac("%0",mactab[x].kwd); /* Define %0 = name of macro */
  8749. makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
  8750. varnam[0] = '%';
  8751. varnam[2] = '\0';
  8752. tra_asg = 0;
  8753. for (y = 1; y < 10; y++) { /* Clear args %1..%9 */
  8754. if (m_arg[maclvl][y]) { /* Don't call delmac() unless */
  8755. varnam[1] = (char) (y + '0'); /* we have to... */
  8756. delmac(varnam,0);
  8757. }
  8758. }
  8759. tra_asg = tra_tmp;
  8760. /* Break the big "s" string up into macro arguments */
  8761. xwords(s,MAXARGLIST,NULL,0);
  8762. #ifndef NOLOCAL
  8763. #ifdef OS2
  8764. term_io = term_io_sav;
  8765. #endif /* OS2 */
  8766. #endif /* NOLOCAL */
  8767. if (tra_cmd)
  8768. printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
  8769. return(1);
  8770. }
  8771. /* Insert "literal" quote around each comma-separated command to prevent */
  8772. /* its premature expansion. Only do this if object command is surrounded */
  8773. /* by braces. */
  8774. static char* flit = "\\flit(";
  8775. int
  8776. litcmd(src,dest,n) char **src, **dest; int n; {
  8777. int bc = 0, pp = 0;
  8778. char c, *s, *lp, *ss;
  8779. s = *src;
  8780. lp = *dest;
  8781. debug(F010,"litcmd",s,0);
  8782. while (*s == SP) s++; /* Strip extra leading spaces */
  8783. if (*s == '{') { /* Starts with brace */
  8784. pp = 0; /* Paren counter */
  8785. bc = 1; /* Count leading brace */
  8786. *lp++ = *s++; /* Copy it */
  8787. if (--n < 1) return(-1); /* Check space */
  8788. while (*s == SP) s++; /* Strip interior leading spaces */
  8789. ss = flit; /* Point to "\flit(" */
  8790. while ((*lp++ = *ss++)) /* Copy it */
  8791. if (--n < 1) /* and check space */
  8792. return(-1);
  8793. lp--; /* Back up over null */
  8794. while (*s) { /* Go thru rest of text */
  8795. c = *s;
  8796. if (c == '{') bc++; /* Count brackets */
  8797. if (c == '(') pp++; /* and parens */
  8798. if (c == ')') { /* Right parenthesis. */
  8799. pp--; /* Count it. */
  8800. if (pp < 0) { /* An unbalanced right paren... */
  8801. #ifdef COMMENT
  8802. /*
  8803. The problem here is that "\{" appears to be a quoted brace and therefore
  8804. isn't counted; then the "}" matches an earlier opening brace, causing
  8805. (e.g.) truncation of macros by getncm().
  8806. */
  8807. if (n < 5) /* Out of space in dest buffer? */
  8808. return(-1); /* If so, give up. */
  8809. *lp++ = CMDQ; /* Must be quoted to prevent */
  8810. *lp++ = '}'; /* premature termination of */
  8811. *lp++ = '4'; /* \flit(...) */
  8812. *lp++ = '1';
  8813. *lp++ = '}';
  8814. n -= 5;
  8815. #else
  8816. /* Here we rely on the fact the \nnn never takes more than 3 digits */
  8817. if (n < 4) /* Out of space in dest buffer? */
  8818. return(-1); /* If so, give up. */
  8819. *lp++ = CMDQ; /* Must be quoted to prevent */
  8820. *lp++ = '0'; /* premature termination of */
  8821. *lp++ = '4'; /* \flit(...) */
  8822. *lp++ = '1';
  8823. n -= 4;
  8824. #endif /* COMMENT */
  8825. pp++; /* Uncount it. */
  8826. s++;
  8827. continue;
  8828. }
  8829. }
  8830. if (c == '}') { /* Closing brace. */
  8831. if (--bc == 0) { /* Final one? */
  8832. *lp++ = ')'; /* Add closing paren for "\flit()" */
  8833. if (--n < 1) return(-1);
  8834. *lp++ = c;
  8835. if (--n < 1) return(-1);
  8836. s++;
  8837. break;
  8838. }
  8839. }
  8840. *lp++ = c; /* General case */
  8841. if (--n < 1) return(-1);
  8842. s++;
  8843. }
  8844. *lp = NUL;
  8845. } else { /* No brackets around, */
  8846. while ((*lp++ = *s++)) /* just copy. */
  8847. if (--n < 1)
  8848. return(-1);
  8849. lp--;
  8850. }
  8851. *src = s; /* Return updated source */
  8852. *dest = lp; /* and destination pointers */
  8853. if (bc) /* Fail if braces unbalanced */
  8854. return(-1);
  8855. else /* Otherwise succeed. */
  8856. return(0);
  8857. }
  8858. #endif /* NOSPL */
  8859. /* Functions moved here from ckuusr.c to even out the module sizes... */
  8860. /*
  8861. Breaks up string s -- IN PLACE! -- into a list of up to max words.
  8862. Pointers to each word go into the array list[].
  8863. max is the maximum number of words (pointers).
  8864. If list is NULL, then they are added to the macro table.
  8865. flag = 0 means the last field is to be one word, like all the other fields,
  8866. so anything after it is discarded.
  8867. flag = 1 means the last field extends to the end of the string, even if
  8868. there are lots of words left, so the last field contains the
  8869. remainder of the string.
  8870. */
  8871. VOID
  8872. xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
  8873. char *p;
  8874. int b, i, k, q, y, z;
  8875. int macro = 0;
  8876. if (!list) {
  8877. debug(F100," xwords list is NULL","",0);
  8878. macro = 1;
  8879. } else {
  8880. debug(F100," xwords LIST is defined","",0);
  8881. }
  8882. debug(F100,"xwords ENTRY","",0);
  8883. #ifndef NOSPL
  8884. /*
  8885. debug(F110," xwords macro",(char *)m_xarg[maclvl][0],0);
  8886. */
  8887. debug(F101," xwords maclvl","",maclvl);
  8888. debug(F101," xwords max","",max);
  8889. debug(F101," xwords flag","",flag);
  8890. debug(F110," xwords string",s,0);
  8891. debug(F101," xwords macro","",macro);
  8892. #endif /* NOSPL */
  8893. p = s; /* Pointer to beginning of string */
  8894. q = 0; /* Flag for doublequote removal */
  8895. b = 0; /* Flag for outer brace removal */
  8896. k = 0; /* Flag for in-word */
  8897. y = 0; /* Brace nesting level */
  8898. z = 0; /* "Word" counter, 0 thru max */
  8899. if (!s) s = ""; /* Nothing to do */
  8900. if (!*s) return;
  8901. if (list)
  8902. for (i = 0; i <= max; i++) /* Initialize pointers */
  8903. list[i] = NULL;
  8904. if (flag) max--;
  8905. #ifndef NOSPL
  8906. /*
  8907. Macro arguments at this point are a single string... must split it up.
  8908. As of C-Kermit 9.0.304 Dev.22, 24 April 2017, we use cksplit() for
  8909. this instead of tons of messy code in xwords() written decades ago
  8910. to do what cksplit() does better.
  8911. */
  8912. if (macro) {
  8913. struct stringarray * q = NULL;
  8914. char **pp = NULL;
  8915. int n;
  8916. if (maclvl < 0) {
  8917. debug(F101," xwords maclvl < 0","",maclvl);
  8918. newerrmsg("Internal error: maclvl < 0");
  8919. }
  8920. debug(F101," xwords splitting macro arguments.. maclvl","",maclvl);
  8921. /* Space is the only separator; grouping is with "" or {} */
  8922. q = cksplit(1,0,p," ","ALL",1+2,0,0,1);
  8923. z = q->a_size; /* Number of "words" in string */
  8924. if (z <= 0) return;
  8925. pp = q->a_head;
  8926. if (pp) {
  8927. /*
  8928. In C-Kermit 9.0.304 Dev.22, April 2017, we have to get the macro arguments
  8929. from the previous macro level (prev). Up to now, the macro arguments were
  8930. evaluated when the DO command was parsed, before dodo() or xwords() were
  8931. ever called. Now we're evaluating them after already entering the new macro
  8932. stack level: evalmacroarg() is just a front end for zzstring(), which is at
  8933. the heart of all variable-substitution operations. To evaluate a \%1-9
  8934. variable, zzstring() looks in the CURRENT macro stack frame. Rather than
  8935. mess with zzstring(), I set maclvl back before calling evalmacroarg() and
  8936. restore it immediately afterward. It's the only safe way to do this,
  8937. Because zzstring() has no way of knowing whether (say) \%1 is on the DO
  8938. command line or in some other context.
  8939. */
  8940. debug(F101," xwords macro cksplit items","",z);
  8941. if (z > max) z = max;
  8942. for (i = 1; i <= z; i++) { /* Loop through macro arguments. */
  8943. p = pp[i];
  8944. debug(F111," xwords arg i",p,i);
  8945. maclvl--; /* Get argument from previous level */
  8946. evalmacroarg(&p); /* Evaluate it */
  8947. maclvl++; /* Use its value on currentlevel */
  8948. debug(F111," xwords arg i evaluated",p,i);
  8949. makestr(&(m_xarg[maclvl][i]),p);
  8950. if (i < 10) {
  8951. varnam[1] = (char) (i + '0'); /* Assign last arg */
  8952. addmac(varnam,p);
  8953. debug(F111," xwords arg name",varnam,maclvl);
  8954. debug(F111," xwords def def ",p,maclvl);
  8955. }
  8956. }
  8957. /* Handle argc and the dimension of the \&_[] arg vector array */
  8958. if (maclvl < 0) { /* (How can this be?) */
  8959. a_dim[0] = z; /* Array dimension is one less */
  8960. topargc = z + 1; /* than \v(argc) */
  8961. debug(F111," xwords a_dim[0]","IMPOSSIBLE",a_dim[0]);
  8962. } else {
  8963. macargc[maclvl] = z + 1; /* Set \v(argc) variable */
  8964. n_xarg[maclvl] = z + 1; /* This is the actual number */
  8965. a_ptr[0] = m_xarg[maclvl]; /* Point \&_[] at the args */
  8966. a_dim[0] = z; /* And give it this dimension */
  8967. debug(F111," xwords a_dim[0]","E",a_dim[0]);
  8968. }
  8969. }
  8970. return;
  8971. }
  8972. #endif /* NOSPL */
  8973. /*
  8974. Not macro args, some other kind of list.
  8975. This whole mess could be a cksplit() call...
  8976. */
  8977. while (1) { /* Go thru word list */
  8978. if (!s || (*s == '\0')) { /* No more characters? */
  8979. if (k != 0) { /* Was I in a word? */
  8980. if (z == max) break; /* Yes, only go up to max. */
  8981. z++; /* Count this word. */
  8982. list[z] = p; /* Assign pointer. */
  8983. debug(F111," xwords list item p z",p,z);
  8984. }
  8985. break; /* And get out. */
  8986. }
  8987. if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
  8988. s++;
  8989. continue;
  8990. } else if (q == 0 && *s == '{') { /* An opening brace */
  8991. if (k == 0 && y == 0) { /* If leading brace */
  8992. p = s+1; /* point past it */
  8993. b = 1; /* and flag that we did this */
  8994. }
  8995. k = 1; /* Flag that we're in a word */
  8996. y++; /* Count the brace. */
  8997. } else if (q == 0 && *s == '}') { /* A closing brace. */
  8998. y--; /* Count it. */
  8999. if (y <= 0 && b != 0) { /* If it matches the leading brace */
  9000. char c;
  9001. c = *(s+1);
  9002. if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9003. *s = SP; /* change it to a space */
  9004. b = 0; /* and we're not in braces any more */
  9005. }
  9006. }
  9007. #ifdef DOUBLEQUOTING
  9008. /* Opening doublequote */
  9009. } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
  9010. y++;
  9011. p = s+1; /* point past it */
  9012. q = 1; /* and flag that we did this */
  9013. k = 1; /* Flag that we're in a word */
  9014. /* Closing double quote */
  9015. } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
  9016. char c;
  9017. c = *(s+1);
  9018. if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
  9019. y--;
  9020. *s = SP; /* change it to a space */
  9021. q = 0; /* and we're not in quotes any more */
  9022. }
  9023. #endif /* DOUBLEQUOTING */
  9024. } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
  9025. if (k == 0) { /* If we weren't in a word before, */
  9026. p = s; /* Mark the beginning */
  9027. if (flag && z == max) { /* Want last word to be remainder? */
  9028. z++;
  9029. list[z] = p; /* Yes, point to it */
  9030. break; /* and quit */
  9031. }
  9032. k = 1; /* Set in-word flag */
  9033. }
  9034. }
  9035. /* If we're not inside a braced quantity, and we are in a word, and */
  9036. /* we have hit whitespace, then we have a word. */
  9037. if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
  9038. if (!flag || z < max) /* if we don't want to keep rest */
  9039. *s = '\0'; /* terminate the arg with null */
  9040. k = 0; /* say we're not in a word any more */
  9041. y = 0; /* start braces off clean again */
  9042. if (z == max) break; /* Only go up to max. */
  9043. z++; /* count this arg */
  9044. list[z] = p;
  9045. p = s+1;
  9046. }
  9047. s++; /* Point past this character */
  9048. }
  9049. if ((z == 0) && (y > 1)) { /* Extra closing brace(s) at end */
  9050. z++;
  9051. list[z] = p;
  9052. }
  9053. return;
  9054. }
  9055. #ifndef NOSPL
  9056. /* D O S H I F T -- Do the SHIFT Command; shift macro args left by n */
  9057. /* Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */
  9058. int
  9059. doshift(n) int n; { /* n = shift count */
  9060. int i, top, level;
  9061. char /* *s, *m, */ buf[6]; /* Buffer to build scalar names */
  9062. char * sx = tmpbuf;
  9063. int nx = TMPBUFSIZ;
  9064. debug(F101,"SHIFT count","",n);
  9065. debug(F101,"SHIFT topargc","",topargc);
  9066. if (n < 1) /* Stay in range */
  9067. return(n == 0 ? 1 : 0);
  9068. level = maclvl;
  9069. top = (level < 0) ? topargc : macargc[level];
  9070. if (n >= top)
  9071. n = top - 1;
  9072. #ifdef DEBUG
  9073. if (deblog) {
  9074. debug(F101,"SHIFT count 2","",n);
  9075. debug(F101,"SHIFT level","",level);
  9076. if (level > -1)
  9077. debug(F101,"SHIFT macargc[level]","",macargc[level]);
  9078. }
  9079. #endif /* DEBUG */
  9080. buf[0] = '\\'; /* Initialize name template */
  9081. buf[1] = '%';
  9082. buf[2] = NUL;
  9083. buf[3] = NUL;
  9084. for (i = 1; i <= n; i++) { /* Free shifted-over args */
  9085. if (level < 0) {
  9086. makestr(&(toparg[i]),NULL);
  9087. } else {
  9088. makestr(&(m_xarg[level][i]),NULL);
  9089. }
  9090. if (i < 10) { /* Is this necessary? */
  9091. buf[2] = (char)(i+'0');
  9092. delmac(buf,0);
  9093. }
  9094. }
  9095. for (i = 1; i <= top-n; i++) { /* Shift remaining args */
  9096. if (level < 0) {
  9097. #ifdef COMMENT
  9098. toparg[i] = toparg[i+n]; /* Full vector */
  9099. #else
  9100. makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
  9101. #endif /* COMMENT */
  9102. if (i < 10) /* Scalars... */
  9103. makestr(&(g_var[i+'0']),toparg[i+n]);
  9104. } else {
  9105. #ifdef COMMENT
  9106. m_xarg[level][i] = m_xarg[level][i+n];
  9107. #else
  9108. makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
  9109. #endif /* COMMENT */
  9110. if (i < 10) {
  9111. buf[2] = (char)(i+'0');
  9112. debug(F010,"SHIFT buf",buf,0);
  9113. addmac(buf,m_xarg[level][i+n]);
  9114. }
  9115. }
  9116. }
  9117. for (i = top-n; i <= top; i++) { /* Clear n args from the end */
  9118. if (level < 0) {
  9119. #ifdef COMMENT
  9120. toparg[i] = NULL;
  9121. #else
  9122. makestr(&(toparg[i]),NULL);
  9123. #endif /* COMMENt */
  9124. if (i < 10)
  9125. makestr(&(g_var[i+'0']),NULL);
  9126. } else {
  9127. #ifdef COMMENT
  9128. m_xarg[level][i] = NULL;
  9129. #else
  9130. makestr(&(m_xarg[level][i]),NULL);
  9131. #endif /* COMMENt */
  9132. if (i < 10) {
  9133. buf[2] = (char)(i+'0');
  9134. delmac(buf,0);
  9135. }
  9136. }
  9137. }
  9138. if (level > -1) { /* Macro args */
  9139. macargc[level] -= n; /* Adjust count */
  9140. n_xarg[maclvl] = macargc[level]; /* Here too */
  9141. a_dim[0] = macargc[level] - 1; /* Adjust array dimension */
  9142. debug(F111,"a_dim[0]","F",a_dim[0]);
  9143. zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
  9144. #ifdef COMMENT
  9145. makestr(&(m_line[level]),tmpbuf);
  9146. #endif /* COMMENT */
  9147. } else { /* Ditto for top level */
  9148. topargc -= n;
  9149. a_dim[0] = topargc - 1;
  9150. debug(F111,"a_dim[0]","G",a_dim[0]);
  9151. zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
  9152. #ifdef COMMENT
  9153. makestr(&topline,tmpbuf);
  9154. #endif /* COMMENT */
  9155. }
  9156. return(1);
  9157. }
  9158. #endif /* NOSPL */
  9159. int
  9160. docd(cx) int cx; { /* Do the CD command */
  9161. int x;
  9162. extern int server, srvcdmsg, cdactive;
  9163. extern char * cdmsgfile[], * ckcdpath;
  9164. char *s, *p;
  9165. #ifdef MAC
  9166. char temp[34];
  9167. #endif /* MAC */
  9168. #ifdef IKSDCONF
  9169. extern int iksdcf;
  9170. #endif /* IKSDCONF */
  9171. #ifndef NOFRILLS
  9172. if (cx == XXBACK) {
  9173. if ((x = cmcfm()) < 0)
  9174. cwdf = 1;
  9175. if (prevdir) {
  9176. s = zgtdir();
  9177. if (!zchdir(prevdir)) {
  9178. cwdf = 0;
  9179. perror(s);
  9180. } else {
  9181. makestr(&prevdir,s);
  9182. }
  9183. }
  9184. return(cwdf);
  9185. }
  9186. #endif /* NOFRILLS */
  9187. if (cx == XXCDUP) {
  9188. #ifdef VMS
  9189. s = "[-]";
  9190. #else
  9191. #ifdef datageneral
  9192. s = "^";
  9193. #else
  9194. s = "..";
  9195. #endif /* datageneral */
  9196. #endif /* VMS */
  9197. ckstrncpy(line,s,LINBUFSIZ);
  9198. goto gocd;
  9199. }
  9200. #ifndef NOSPL
  9201. if (cx == XXKCD) { /* Symbolic (Kermit) CD */
  9202. char * p;
  9203. int n, k;
  9204. x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
  9205. if (x < 0)
  9206. return(x);
  9207. x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
  9208. if (x < 0) {
  9209. printf("?Lookup error\n"); /* shouldn't happen */
  9210. return(-9);
  9211. }
  9212. if ((x = cmcfm()) < 0)
  9213. return(x);
  9214. if (k == VN_HOME) { /* HOME: allow SET HOME to override */
  9215. ckstrncpy(line,homepath(),LINBUFSIZ);
  9216. } else { /* Other symbolic name */
  9217. /* Convert to variable syntax */
  9218. ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
  9219. p = line; /* Expand the variable */
  9220. n = LINBUFSIZ;
  9221. zzstring(tmpbuf,&p,&n);
  9222. if (!line[0]) { /* Fail if variable not defined */
  9223. printf("?%s - not defined\n",tmpbuf);
  9224. return(success = 0);
  9225. }
  9226. }
  9227. s = line; /* All OK, go try to CD... */
  9228. goto gocd;
  9229. }
  9230. #endif /* NOSPL */
  9231. cdactive = 1;
  9232. #ifdef GEMDOS
  9233. if ((x = cmdir("Name of local directory, or carriage return",
  9234. homepath(),
  9235. &s,
  9236. NULL
  9237. )
  9238. ) < 0 )
  9239. return(x);
  9240. #else
  9241. #ifdef OS2
  9242. if ((x = cmdirp("Name of PC disk and/or directory,\n\
  9243. or press the Enter key for the default",
  9244. homepath(),
  9245. &s,
  9246. ckcdpath ? ckcdpath : getenv("CDPATH"),
  9247. xxstring
  9248. )
  9249. ) < 0 )
  9250. return(x);
  9251. #else
  9252. #ifdef MAC
  9253. x = ckstrncpy(temp,homepath(),32);
  9254. if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
  9255. if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
  9256. or press the Return key for the desktop on the boot disk",
  9257. temp,&s, xxstring)) < 0 )
  9258. return(x);
  9259. #else
  9260. if ((x = cmdirp("Carriage return for home directory,\n\
  9261. or name of directory on this computer",
  9262. #ifdef VMS
  9263. "SYS$LOGIN", /* With no colon */
  9264. #else
  9265. homepath(), /* In VMS this is "SYS$LOGIN:" */
  9266. #endif /* VMS */
  9267. &s,
  9268. ckcdpath ? ckcdpath : getenv("CDPATH"),
  9269. xxstring
  9270. )) < 0)
  9271. return(x);
  9272. #endif /* MAC */
  9273. #endif /* OS2 */
  9274. #endif /* GEMDOS */
  9275. ckstrncpy(line,s,LINBUFSIZ); /* Make a safe copy */
  9276. s = line;
  9277. #ifdef VMS
  9278. if (ckmatch("*.DIR;1$",s,0,0))
  9279. if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
  9280. s = tmpbuf;
  9281. #endif /* VMS */
  9282. debug(F110,"docd",s,0);
  9283. #ifndef MAC
  9284. if ((x = cmcfm()) < 0) /* Get confirmation */
  9285. return(x);
  9286. #endif /* MAC */
  9287. gocd:
  9288. #ifdef datageneral
  9289. x = strlen(line); /* homdir ends in colon, */
  9290. if (x > 1 && line[x-1] == ':') /* and "dir" doesn't like that... */
  9291. line[x-1] = NUL;
  9292. #endif /* datageneral */
  9293. #ifdef MAC
  9294. cwdf = 1;
  9295. if (!zchdir(s)) {
  9296. cwdf = 0;
  9297. if (*s != ':') { /* If it failed, */
  9298. char *p; /* supply leading colon */
  9299. int len = (int)strlen(s) + 2;
  9300. p = malloc(len); /* and try again... */
  9301. if (p) {
  9302. strcpy(p,":"); /* safe */
  9303. strcat(p,s); /* safe */
  9304. if (zchdir(p))
  9305. cwdf = 1;
  9306. free(p);
  9307. p = NULL;
  9308. }
  9309. }
  9310. }
  9311. if (!cwdf)
  9312. perror(s);
  9313. #else
  9314. p = zgtdir();
  9315. if (!zchdir(s)) {
  9316. cwdf = 0;
  9317. #ifdef CKROOT
  9318. if (ckrooterr)
  9319. printf("?Off limits: \"%s\"\n",s);
  9320. else
  9321. #endif /* CKROOT */
  9322. perror(s);
  9323. } else cwdf = 1;
  9324. #endif /* MAC */
  9325. x = 0;
  9326. if (cwdf) {
  9327. makestr(&prevdir,p);
  9328. debug(F111,"docd","srvcdmsg",srvcdmsg);
  9329. if (srvcdmsg
  9330. #ifdef IKSDCONF
  9331. && !(inserver && !iksdcf)
  9332. #endif /* IKSDCONF */
  9333. ) {
  9334. int i;
  9335. for (i = 0; i < 8; i++) {
  9336. debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
  9337. if (zchki(cdmsgfile[i]) > -1) {
  9338. x = 1;
  9339. dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
  9340. break;
  9341. }
  9342. }
  9343. }
  9344. }
  9345. /* xdocd: */
  9346. if (!x && srvcdmsg && !server
  9347. #ifdef IKSDCONF
  9348. && !(inserver && !iksdcf)
  9349. #endif /* IKSDCONF */
  9350. && !quiet && !xcmdsrc)
  9351. printf("%s\n", zgtdir());
  9352. return(cwdf);
  9353. }
  9354. static int on_ctrlc = 0;
  9355. VOID
  9356. fixcmd() { /* Fix command parser after interruption */
  9357. #ifndef NOSPL
  9358. #ifndef NOONCTRLC
  9359. if (nmac) { /* Any macros defined? */
  9360. int k; /* Yes */
  9361. char * s = "on_ctrlc"; /* Name of Ctrl-C handling macro */
  9362. k = mlook(mactab,s,nmac); /* Look it up. */
  9363. if (k >= 0) { /* If found, */
  9364. if (on_ctrlc++ == 0) { /* if not already executing, */
  9365. if (dodo(k,"",0) > -1) /* set it up, */
  9366. parser(1); /* execute it, */
  9367. }
  9368. delmac(s,1); /* and undefine it. */
  9369. }
  9370. }
  9371. on_ctrlc = 0;
  9372. #endif /* NOONCTRLC */
  9373. #endif /* NOSPL */
  9374. dostop(); /* Back to top level (also calls conint()). */
  9375. bgchk(); /* Check background status */
  9376. if (*psave) { /* If old prompt saved, */
  9377. cmsetp(psave); /* restore it. */
  9378. *psave = NUL;
  9379. }
  9380. success = 0; /* Tell parser last command failed */
  9381. }
  9382. #ifndef NOSHOW /* SHOW FEATURES */
  9383. /*
  9384. Note, presently optlist[] index overflow is not checked.
  9385. There is plenty of room (less than 360 entries for 1000 slots).
  9386. When space starts to get tight, check for noptlist >= NOPTLIST
  9387. every time noptlist is incremented.
  9388. */
  9389. #define NOPTLIST 1024
  9390. static int noptlist = 0;
  9391. static char * optlist[NOPTLIST+1];
  9392. static int hpos = 0;
  9393. int
  9394. prtopt(lines,s) int * lines; char *s; { /* Print an option */
  9395. int y, i; /* Does word wrap. */
  9396. if (!s) s = "";
  9397. i = *lines;
  9398. if (!*s) { /* Empty argument */
  9399. if (hpos > 0) { /* means to end this line. */
  9400. printf("\n"); /* Not needed if already at */
  9401. if (++i > (cmd_rows - 3)) { /* beginning of new line. */
  9402. if (!askmore())
  9403. return(0);
  9404. else
  9405. i = 0;
  9406. }
  9407. }
  9408. printf("\n"); /* And then make a blank line */
  9409. if (++i > (cmd_rows - 3)) {
  9410. if (!askmore())
  9411. return(0);
  9412. else
  9413. i = 0;
  9414. }
  9415. hpos = 0;
  9416. *lines = i;
  9417. return(1);
  9418. }
  9419. y = (int)strlen(s) + 1;
  9420. hpos += y;
  9421. debug(F101,"prtopt hpos","",hpos);
  9422. debug(F101,"prtopt cmd_cols","",cmd_cols);
  9423. if (
  9424. #ifdef OS2
  9425. hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
  9426. #else /* OS2 */
  9427. hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
  9428. #endif /* OS2 */
  9429. ) {
  9430. printf("\n");
  9431. if (++i > (cmd_rows - 3)) {
  9432. if (!askmore())
  9433. return(0);
  9434. else
  9435. i = 0;
  9436. }
  9437. printf(" %s",s);
  9438. hpos = y;
  9439. } else
  9440. printf(" %s",s);
  9441. *lines = i;
  9442. return(1);
  9443. }
  9444. static VOID
  9445. initoptlist() {
  9446. int i;
  9447. if (noptlist > 0)
  9448. return;
  9449. for (i = 0; i < NOPTLIST; i++)
  9450. optlist[i] = NULL;
  9451. #ifdef MAC
  9452. #ifdef MPW
  9453. makestr(&(optlist[noptlist++]),"MPW");
  9454. #endif /* MPW */
  9455. #endif /* MAC */
  9456. #ifdef MAC
  9457. #ifdef THINK_C
  9458. makestr(&(optlist[noptlist++]),"THINK_C");
  9459. #endif /* THINK_C */
  9460. #endif /* MAC */
  9461. #ifdef __386__
  9462. makestr(&(optlist[noptlist++]),"__386__");
  9463. #endif /* __386__ */
  9464. /* Memory models... */
  9465. #ifdef __FLAT__
  9466. makestr(&(optlist[noptlist++]),"__FLAT__");
  9467. #endif /* __FLAT__ */
  9468. #ifdef __SMALL__
  9469. makestr(&(optlist[noptlist++]),"__SMALL__");
  9470. #endif /* __SMALL__ */
  9471. #ifdef __MEDIUM__
  9472. makestr(&(optlist[noptlist++]),"__MEDIUM__");
  9473. #endif /* __MEDIUM__ */
  9474. #ifdef __COMPACT__
  9475. makestr(&(optlist[noptlist++]),"__COMPACT__");
  9476. #endif /* __COMPACT__ */
  9477. #ifdef __LARGE__
  9478. makestr(&(optlist[noptlist++]),"__LARGE__");
  9479. #endif /* __LARGE__ */
  9480. #ifdef DEBUG
  9481. #ifdef IFDEBUG
  9482. makestr(&(optlist[noptlist++]),"IFDEBUG");
  9483. #else
  9484. makestr(&(optlist[noptlist++]),"DEBUG");
  9485. #endif /* IFDEBUG */
  9486. #endif /* DEBUG */
  9487. #ifdef TLOG
  9488. makestr(&(optlist[noptlist++]),"TLOG");
  9489. #endif /* TLOG */
  9490. #ifdef BIGBUFOK
  9491. makestr(&(optlist[noptlist++]),"BIGBUFOK");
  9492. #endif /* BIGBUFOK */
  9493. #ifdef INPBUFSIZ
  9494. sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
  9495. makestr(&(optlist[noptlist++]),line);
  9496. #endif /* INPBUFSIZE */
  9497. #ifdef LINBUFSIZ
  9498. sprintf(line,"LINBUFSIZ=%d",LINBUFSIZ); /* SAFE */
  9499. makestr(&(optlist[noptlist++]),line);
  9500. #endif /* LINBUFSIZE */
  9501. #ifdef INBUFSIZE
  9502. sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
  9503. makestr(&(optlist[noptlist++]),line);
  9504. #endif /* INBUFSIZE */
  9505. #ifdef OBUFSIZE
  9506. sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
  9507. makestr(&(optlist[noptlist++]),line);
  9508. #endif /* OBUFSIZE */
  9509. #ifdef FD_SETSIZE
  9510. sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
  9511. makestr(&(optlist[noptlist++]),line);
  9512. #endif /* FD_SETSIZE */
  9513. #ifdef XFRCAN
  9514. makestr(&(optlist[noptlist++]),"XFRCAN");
  9515. #endif /* XFRCAN */
  9516. #ifdef XPRINT
  9517. makestr(&(optlist[noptlist++]),"XPRINT");
  9518. #endif /* XPRINT */
  9519. #ifdef PIPESEND
  9520. makestr(&(optlist[noptlist++]),"PIPESEND");
  9521. #endif /* PIPESEND */
  9522. #ifdef CK_SPEED
  9523. makestr(&(optlist[noptlist++]),"CK_SPEED");
  9524. #endif /* CK_SPEED */
  9525. #ifdef CK_FAST
  9526. makestr(&(optlist[noptlist++]),"CK_FAST");
  9527. #endif /* CK_FAST */
  9528. #ifdef CK_APC
  9529. makestr(&(optlist[noptlist++]),"CK_APC");
  9530. #endif /* CK_APC */
  9531. #ifdef CK_AUTODL
  9532. makestr(&(optlist[noptlist++]),"CK_AUTODL");
  9533. #endif /* CK_AUTODL */
  9534. #ifdef CK_MKDIR
  9535. makestr(&(optlist[noptlist++]),"CK_MKDIR");
  9536. #endif /* CK_MKDIR */
  9537. #ifdef HAVE_LOCALE
  9538. makestr(&(optlist[noptlist++]),"HAVE_LOCALE");
  9539. #endif /* HAVE_LOCALE */
  9540. #ifdef HAVE_SNPRINTF
  9541. makestr(&(optlist[noptlist++]),"HAVE_SNPRINTF");
  9542. #endif /* HAVE_SNPRINTF */
  9543. #ifdef NOMKDIR
  9544. makestr(&(optlist[noptlist++]),"NOMKDIR");
  9545. #endif /* NOMKDIR */
  9546. #ifdef CK_LABELED
  9547. makestr(&(optlist[noptlist++]),"CK_LABELED");
  9548. #endif /* CK_LABELED */
  9549. #ifdef NODIAL
  9550. makestr(&(optlist[noptlist++]),"NODIAL");
  9551. #endif /* NODIAL */
  9552. #ifdef MINIDIAL
  9553. makestr(&(optlist[noptlist++]),"MINIDIAL");
  9554. #endif /* MINIDIAL */
  9555. #ifdef WHATAMI
  9556. makestr(&(optlist[noptlist++]),"WHATAMI");
  9557. #endif /* WHATAMI */
  9558. #ifdef DYNAMIC
  9559. makestr(&(optlist[noptlist++]),"DYNAMIC");
  9560. #endif /* DYNAMIC */
  9561. #ifndef NOSPL
  9562. sprintf(line,"CMDDEP=%d",CMDDEP); /* SAFE */
  9563. makestr(&(optlist[noptlist++]),line);
  9564. #endif /* NOSPL */
  9565. #ifdef MAXPATHLEN
  9566. sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
  9567. makestr(&(optlist[noptlist++]),line);
  9568. #endif /* MAXPATHLEN */
  9569. #ifdef DEVNAMLEN
  9570. sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
  9571. makestr(&(optlist[noptlist++]),line);
  9572. #endif /* DEVNAMLEN */
  9573. #ifdef NO_PARAM_H
  9574. makestr(&(optlist[noptlist++]),"NO_PARAM_H");
  9575. #endif /* NO_PARAM_H */
  9576. #ifdef INCL_PARAM_H
  9577. makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
  9578. #endif /* INCL_PARAM_H */
  9579. sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
  9580. makestr(&(optlist[noptlist++]),line);
  9581. sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
  9582. makestr(&(optlist[noptlist++]),line);
  9583. #ifndef UNIX
  9584. /*
  9585. These aren't actually used... In Unix we get maximum number of open
  9586. files from sysconf() at runtime.
  9587. */
  9588. sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
  9589. makestr(&(optlist[noptlist++]),line);
  9590. #ifdef OPEN_MAX
  9591. sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
  9592. makestr(&(optlist[noptlist++]),line);
  9593. #endif /* OPEN_MAX */
  9594. #ifdef _POSIX_OPEN_MAX
  9595. sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
  9596. makestr(&(optlist[noptlist++]),line);
  9597. #endif /* _POSIX_OPEN_MAX */
  9598. #endif /* UNIX */
  9599. #ifdef CKCHANNELIO
  9600. {
  9601. extern int z_maxchan;
  9602. #ifdef UNIX
  9603. extern int ckmaxfiles;
  9604. sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
  9605. makestr(&(optlist[noptlist++]),line);
  9606. #endif /* UNIX */
  9607. sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
  9608. makestr(&(optlist[noptlist++]),line);
  9609. }
  9610. #endif /* CKCHANNELIO */
  9611. #ifdef FOPEN_MAX
  9612. sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
  9613. makestr(&(optlist[noptlist++]),line);
  9614. #endif /* FOPEN_MAX */
  9615. #ifdef MAXGETPATH
  9616. sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
  9617. makestr(&(optlist[noptlist++]),line);
  9618. #endif /* MAXGETPATH */
  9619. #ifdef CMDBL
  9620. sprintf(line,"CMDBL=%d",CMDBL); /* SAFE */
  9621. makestr(&(optlist[noptlist++]),line);
  9622. #endif /* CMDBL */
  9623. #ifdef VNAML
  9624. sprintf(line,"VNAML=%d",VNAML); /* SAFE */
  9625. makestr(&(optlist[noptlist++]),line);
  9626. #endif /* VNAML */
  9627. #ifdef ARRAYREFLEN
  9628. sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
  9629. makestr(&(optlist[noptlist++]),line);
  9630. #endif /* ARRAYREFLEN */
  9631. #ifdef UIDBUFLEN
  9632. sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
  9633. makestr(&(optlist[noptlist++]),line);
  9634. #endif /* UIDBUFLEN */
  9635. #ifdef FORDEPTH
  9636. sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
  9637. makestr(&(optlist[noptlist++]),line);
  9638. #endif /* FORDEPTH */
  9639. #ifdef MAXTAKE
  9640. sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
  9641. makestr(&(optlist[noptlist++]),line);
  9642. #endif /* MAXTAKE */
  9643. #ifdef MACLEVEL
  9644. sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
  9645. makestr(&(optlist[noptlist++]),line);
  9646. #endif /* MACLEVEL */
  9647. #ifdef MAC_MAX
  9648. sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
  9649. makestr(&(optlist[noptlist++]),line);
  9650. #endif /* MAC_MAX */
  9651. #ifdef _LARGEFILE_SOURCE
  9652. makestr(&(optlist[noptlist++]),"_LARGEFILE_SOURCE");
  9653. #endif /* _LARGEFILE_SOURCE */
  9654. #ifdef _FILE_OFFSET_BITS
  9655. sprintf(line,"_FILE_OFFSET_BITS=%d",_FILE_OFFSET_BITS); /* SAFE */
  9656. makestr(&(optlist[noptlist++]),line);
  9657. #endif /* _FILE_OFFSET_BITS */
  9658. #ifdef __USE_FILE_OFFSET64
  9659. makestr(&(optlist[noptlist++]),"__USE_FILE_OFFSET64");
  9660. #endif /* __USE_FILE_OFFSET64 */
  9661. #ifdef __USE_LARGEFILE64
  9662. makestr(&(optlist[noptlist++]),"__USE_LARGEFILE64");
  9663. #endif /* __USE_LARGEFILE64 */
  9664. #ifdef COMMENT
  9665. #ifdef CHAR_MAX
  9666. sprintf(line,"CHAR_MAX=%llx",CHAR_MAX); /* SAFE */
  9667. makestr(&(optlist[noptlist++]),line);
  9668. #endif /* CHAR_MAX */
  9669. #ifdef UCHAR_MAX
  9670. sprintf(line,"UCHAR_MAX=%llx",UCHAR_MAX); /* SAFE */
  9671. makestr(&(optlist[noptlist++]),line);
  9672. #endif /* UCHAR_MAX */
  9673. #ifdef SHRT_MAX
  9674. sprintf(line,"SHRT_MAX=%llx",SHRT_MAX); /* SAFE */
  9675. makestr(&(optlist[noptlist++]),line);
  9676. #endif /* SHRT_MAX */
  9677. #ifdef USHRT_MAX
  9678. sprintf(line,"USHRT_MAX=%llx",USHRT_MAX); /* SAFE */
  9679. makestr(&(optlist[noptlist++]),line);
  9680. #endif /* USHRT_MAX */
  9681. #ifdef INT_MAX
  9682. sprintf(line,"INT_MAX=%llx",INT_MAX); /* SAFE */
  9683. makestr(&(optlist[noptlist++]),line);
  9684. #endif /* INT_MAX */
  9685. #ifdef UINT_MAX
  9686. sprintf(line,"UINT_MAX=%llx",UINT_MAX); /* SAFE */
  9687. makestr(&(optlist[noptlist++]),line);
  9688. #endif /* UINT_MAX */
  9689. #ifdef MAX_LONG
  9690. sprintf(line,"MAX_LONG=%llx",MAX_LONG); /* SAFE */
  9691. makestr(&(optlist[noptlist++]),line);
  9692. #endif /* MAX_LONG */
  9693. #ifdef LONG_MAX
  9694. sprintf(line,"LONG_MAX=%llx",LONG_MAX); /* SAFE */
  9695. makestr(&(optlist[noptlist++]),line);
  9696. #endif /* LONG_MAX */
  9697. #ifdef ULONG_MAX
  9698. sprintf(line,"ULONG_MAX=%llx",ULONG_MAX); /* SAFE */
  9699. makestr(&(optlist[noptlist++]),line);
  9700. #endif /* ULONG_MAX */
  9701. #ifdef MAXINT
  9702. sprintf(line,"MAXINT=%llx",MAXINT); /* SAFE */
  9703. makestr(&(optlist[noptlist++]),line);
  9704. #endif /* MAXINT */
  9705. #ifdef MAXLONG
  9706. sprintf(line,"MAXLONG=%llx",MAXLONG); /* SAFE */
  9707. makestr(&(optlist[noptlist++]),line);
  9708. #endif /* MAXLONG */
  9709. #ifdef NT
  9710. #ifdef LLONG_MAX
  9711. sprintf(line,"LLONG_MAX=%I64x",LLONG_MAX); /* SAFE */
  9712. makestr(&(optlist[noptlist++]),line);
  9713. #endif /* LLONG_MAX */
  9714. #ifdef ULLONG_MAX
  9715. sprintf(line,"ULLONG_MAX=%I64x",ULLONG_MAX); /* SAFE */
  9716. makestr(&(optlist[noptlist++]),line);
  9717. #endif /* ULLONG_MAX */
  9718. #ifdef MAXLONGLONG
  9719. sprintf(line,"MAXLONGLONG=%I64x",MAXLONGLONG); /* SAFE */
  9720. makestr(&(optlist[noptlist++]),line);
  9721. #endif /* MAXLONGLONG */
  9722. #else
  9723. #ifdef LLONG_MAX
  9724. sprintf(line,"LLONG_MAX=%llx",LLONG_MAX); /* SAFE */
  9725. makestr(&(optlist[noptlist++]),line);
  9726. #endif /* LLONG_MAX */
  9727. #ifdef ULLONG_MAX
  9728. sprintf(line,"ULLONG_MAX=%llx",ULLONG_MAX); /* SAFE */
  9729. makestr(&(optlist[noptlist++]),line);
  9730. #endif /* ULLONG_MAX */
  9731. #ifdef MAXLONGLONG
  9732. sprintf(line,"MAXLONGLONG=%llx",MAXLONGLONG); /* SAFE */
  9733. makestr(&(optlist[noptlist++]),line);
  9734. #endif /* MAXLONGLONG */
  9735. #endif
  9736. #ifdef _INTEGRAL_MAX_BITS
  9737. sprintf(line,"_INTEGRAL_MAX_BITS=%d",_INTEGRAL_MAX_BITS); /* SAFE */
  9738. makestr(&(optlist[noptlist++]),line);
  9739. #endif /* _INTEGRAL_MAX_BITS */
  9740. #endif /* COMMENT */
  9741. #ifdef MINPUTMAX
  9742. sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
  9743. makestr(&(optlist[noptlist++]),line);
  9744. #endif /* MINPUTMAX */
  9745. #ifdef MAXWLD
  9746. sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
  9747. makestr(&(optlist[noptlist++]),line);
  9748. #else
  9749. #ifdef OS2
  9750. makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
  9751. #endif /* OS2 */
  9752. #endif /* MAXWLD */
  9753. #ifdef MSENDMAX
  9754. sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
  9755. makestr(&(optlist[noptlist++]),line);
  9756. #endif /* MSENDMAX */
  9757. #ifdef MAXDDIR
  9758. sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
  9759. makestr(&(optlist[noptlist++]),line);
  9760. #endif /* MAXDDIR */
  9761. #ifdef MAXDNUMS
  9762. sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
  9763. makestr(&(optlist[noptlist++]),line);
  9764. #endif /* MAXDNUMS */
  9765. #ifdef UNIX
  9766. makestr(&(optlist[noptlist++]),"UNIX");
  9767. #endif /* UNIX */
  9768. #ifdef VMS
  9769. makestr(&(optlist[noptlist++]),"VMS");
  9770. #ifdef __VMS_VER
  9771. sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
  9772. makestr(&(optlist[noptlist++]),line);
  9773. #endif /* __VMS_VER */
  9774. #ifdef VMSV70
  9775. makestr(&(optlist[noptlist++]),"VMSV70");
  9776. #endif /* VMSV70 */
  9777. #ifdef OLD_VMS
  9778. makestr(&(optlist[noptlist++]),"OLD_VMS");
  9779. #endif /* OLD_VMS */
  9780. #ifdef vms
  9781. makestr(&(optlist[noptlist++]),"vms");
  9782. #endif /* vms */
  9783. #ifdef VMSV60
  9784. makestr(&(optlist[noptlist++]),"VMSV60");
  9785. #endif /* VMSV60 */
  9786. #ifdef VMSV80
  9787. makestr(&(optlist[noptlist++]),"VMSV80");
  9788. #endif /* VMSV80 */
  9789. #ifdef VMSSHARE
  9790. makestr(&(optlist[noptlist++]),"VMSSHARE");
  9791. #endif /* VMSSHARE */
  9792. #ifdef NOVMSSHARE
  9793. makestr(&(optlist[noptlist++]),"NOVMSSHARE");
  9794. #endif /* NOVMSSHARE */
  9795. #endif /* VMS */
  9796. #ifdef datageneral
  9797. makestr(&(optlist[noptlist++]),"datageneral");
  9798. #endif /* datageneral */
  9799. #ifdef apollo
  9800. makestr(&(optlist[noptlist++]),"apollo");
  9801. #endif /* apollo */
  9802. #ifdef aegis
  9803. makestr(&(optlist[noptlist++]),"aegis");
  9804. #endif /* aegis */
  9805. #ifdef A986
  9806. makestr(&(optlist[noptlist++]),"A986");
  9807. #endif /* A986 */
  9808. #ifdef AMIGA
  9809. makestr(&(optlist[noptlist++]),"AMIGA");
  9810. #endif /* AMIGA */
  9811. #ifdef CONVEX9
  9812. makestr(&(optlist[noptlist++]),"CONVEX9");
  9813. #endif /* CONVEX9 */
  9814. #ifdef CONVEX10
  9815. makestr(&(optlist[noptlist++]),"CONVEX10");
  9816. #endif /* CONVEX9 */
  9817. #ifdef MAC
  9818. makestr(&(optlist[noptlist++]),"MAC");
  9819. #endif /* MAC */
  9820. #ifdef AUX
  9821. makestr(&(optlist[noptlist++]),"AUX");
  9822. #endif /* AUX */
  9823. #ifdef OS2
  9824. makestr(&(optlist[noptlist++]),"OS2");
  9825. #ifdef NT
  9826. makestr(&(optlist[noptlist++]),"NT");
  9827. #endif /* NT */
  9828. #endif /* OS2 */
  9829. #ifdef OSK
  9830. makestr(&(optlist[noptlist++]),"OS9");
  9831. #endif /* OSK */
  9832. #ifdef MSDOS
  9833. makestr(&(optlist[noptlist++]),"MSDOS");
  9834. #endif /* MSDOS */
  9835. #ifdef DIRENT
  9836. makestr(&(optlist[noptlist++]),"DIRENT");
  9837. #endif /* DIRENT */
  9838. #ifdef SDIRENT
  9839. makestr(&(optlist[noptlist++]),"SDIRENT");
  9840. #endif /* SDIRENT */
  9841. #ifdef NDIR
  9842. makestr(&(optlist[noptlist++]),"NDIR");
  9843. #endif /* NDIR */
  9844. #ifdef XNDIR
  9845. makestr(&(optlist[noptlist++]),"XNDIR");
  9846. #endif /* XNDIR */
  9847. #ifdef SAVEDUID
  9848. makestr(&(optlist[noptlist++]),"SAVEDUID");
  9849. #endif /* SAVEDUID */
  9850. #ifdef RENAME
  9851. makestr(&(optlist[noptlist++]),"RENAME");
  9852. #endif /* RENAME */
  9853. #ifdef CK_TMPDIR
  9854. makestr(&(optlist[noptlist++]),"CK_TMPDIR");
  9855. #endif /* CK_TMPDIR */
  9856. #ifdef NOCCTRAP
  9857. makestr(&(optlist[noptlist++]),"NOCCTRAP");
  9858. #endif /* NOCCTRAP */
  9859. #ifdef NOCOTFMC
  9860. makestr(&(optlist[noptlist++]),"NOCOTFMC");
  9861. #endif /* NOCOTFMC */
  9862. #ifdef NOFRILLS
  9863. makestr(&(optlist[noptlist++]),"NOFRILLS");
  9864. #endif /* NOFRILLS */
  9865. #ifdef PARSENSE
  9866. makestr(&(optlist[noptlist++]),"PARSENSE");
  9867. #endif /* PARSENSE */
  9868. #ifdef TIMEH
  9869. makestr(&(optlist[noptlist++]),"TIMEH");
  9870. #endif /* TIMEH */
  9871. #ifdef NOTIMEH
  9872. makestr(&(optlist[noptlist++]),"TIMEH");
  9873. #endif /* NOTIMEH */
  9874. #ifdef SYSTIMEH
  9875. makestr(&(optlist[noptlist++]),"SYSTIMEH");
  9876. #endif /* SYSTIMEH */
  9877. #ifdef NOSYSTIMEH
  9878. makestr(&(optlist[noptlist++]),"SYSTIMEH");
  9879. #endif /* NOSYSTIMEH */
  9880. #ifdef SYSTIMEBH
  9881. makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  9882. #endif /* SYSTIMEBH */
  9883. #ifdef NOSYSTIMEBH
  9884. makestr(&(optlist[noptlist++]),"SYSTIMEBH");
  9885. #endif /* NOSYSTIMEBH */
  9886. #ifdef UTIMEH
  9887. makestr(&(optlist[noptlist++]),"UTIMEH");
  9888. #endif /* UTIMEH */
  9889. #ifdef SYSUTIMEH
  9890. makestr(&(optlist[noptlist++]),"SYSUTIMEH");
  9891. #endif /* SYSUTIMEH */
  9892. #ifdef CK_NEED_SIG
  9893. makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
  9894. #endif /* CK_NEED_SIG */
  9895. #ifdef CK_TTYFD
  9896. makestr(&(optlist[noptlist++]),"CK_TTYFD");
  9897. #endif /* CK_TTYFD */
  9898. #ifdef NETCONN
  9899. makestr(&(optlist[noptlist++]),"NETCONN");
  9900. #endif /* NETCONN */
  9901. #ifdef TCPSOCKET
  9902. makestr(&(optlist[noptlist++]),"TCPSOCKET");
  9903. #ifdef NOTCPOPTS
  9904. makestr(&(optlist[noptlist++]),"NOTCPOPTS");
  9905. #endif /* NOTCPOPTS */
  9906. #ifdef CK_DNS_SRV
  9907. makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
  9908. #endif /* CK_DNS_SRV */
  9909. #ifdef NO_DNS_SRV
  9910. makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
  9911. #endif /* NO_DNS_SRV */
  9912. #ifdef CKGHNLHOST
  9913. makestr(&(optlist[noptlist++]),"CKGHNLHOST");
  9914. #endif /* CKGHNLHOST */
  9915. #ifdef NOLISTEN
  9916. makestr(&(optlist[noptlist++]),"NOLISTEN");
  9917. #endif /* NOLISTEN */
  9918. #ifdef SOL_SOCKET
  9919. makestr(&(optlist[noptlist++]),"SOL_SOCKET");
  9920. #endif /* SOL_SOCKET */
  9921. #ifdef SO_OOBINLINE
  9922. makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
  9923. #endif /* SO_OOBINLNE */
  9924. #ifdef SO_DONTROUTE
  9925. makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
  9926. #endif /* SO_DONTROUTE */
  9927. #ifdef SO_KEEPALIVE
  9928. makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
  9929. #endif /* SO_KEEPALIVE */
  9930. #ifdef SO_LINGER
  9931. makestr(&(optlist[noptlist++]),"SO_LINGER");
  9932. #endif /* SO_LINGER */
  9933. #ifdef TCP_NODELAY
  9934. makestr(&(optlist[noptlist++]),"TCP_NODELAY");
  9935. #endif /* TCP_NODELAY */
  9936. #ifdef SO_SNDBUF
  9937. makestr(&(optlist[noptlist++]),"SO_SNDBUF");
  9938. #endif /* SO_SNDBUF */
  9939. #ifdef SO_RCVBUF
  9940. makestr(&(optlist[noptlist++]),"SO_RCVBUF");
  9941. #endif /* SO_RCVBUF */
  9942. #ifdef h_addr
  9943. makestr(&(optlist[noptlist++]),"h_addr");
  9944. #endif /* h_addr */
  9945. #ifdef HADDRLIST
  9946. makestr(&(optlist[noptlist++]),"HADDRLIST");
  9947. #endif /* HADDRLIST */
  9948. #ifdef CK_SOCKS
  9949. makestr(&(optlist[noptlist++]),"CK_SOCKS");
  9950. #ifdef CK_SOCKS5
  9951. makestr(&(optlist[noptlist++]),"CK_SOCKS5");
  9952. #endif /* CK_SOCKS5 */
  9953. #ifdef CK_SOCKS_NS
  9954. makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
  9955. #endif /* CK_SOCKS_NS */
  9956. #endif /* CK_SOCKS */
  9957. #ifdef RLOGCODE
  9958. makestr(&(optlist[noptlist++]),"RLOGCODE");
  9959. #endif /* RLOGCODE */
  9960. #ifdef NETCMD
  9961. makestr(&(optlist[noptlist++]),"NETCMD");
  9962. #endif /* NETCMD */
  9963. #ifdef NONETCMD
  9964. makestr(&(optlist[noptlist++]),"NONETCMD");
  9965. #endif /* NONETCMD */
  9966. #ifdef NETPTY
  9967. makestr(&(optlist[noptlist++]),"NETPTY");
  9968. #endif /* NETPTY */
  9969. #ifdef CK_ENVIRONMENT
  9970. makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
  9971. #endif /* CK_ENVIRONMENT */
  9972. #endif /* TCPSOCKET */
  9973. #ifdef TNCODE
  9974. makestr(&(optlist[noptlist++]),"TNCODE");
  9975. #endif /* TNCODE */
  9976. #ifdef CK_FORWARD_X
  9977. makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
  9978. #endif /* CK_FORWARD_X */
  9979. #ifdef TN_COMPORT
  9980. makestr(&(optlist[noptlist++]),"TN_COMPORT");
  9981. #endif /* TN_COMPORT */
  9982. #ifdef MULTINET
  9983. makestr(&(optlist[noptlist++]),"MULTINET");
  9984. #endif /* MULTINET */
  9985. #ifdef DEC_TCPIP
  9986. makestr(&(optlist[noptlist++]),"DEC_TCPIP");
  9987. #endif /* DEC_TCPIP */
  9988. #ifdef TCPWARE
  9989. makestr(&(optlist[noptlist++]),"TCPWARE");
  9990. #endif /* TCPWARE */
  9991. #ifdef UCX50
  9992. makestr(&(optlist[noptlist++]),"UCX50");
  9993. #endif /* UCX50 */
  9994. #ifdef CMU_TCPIP
  9995. makestr(&(optlist[noptlist++]),"CMU_TCPIP");
  9996. #endif /* CMU_TCPIP */
  9997. #ifdef TTLEBUF
  9998. makestr(&(optlist[noptlist++]),"TTLEBUF");
  9999. #endif /* TTLEBUF */
  10000. #ifdef NETLEBUF
  10001. makestr(&(optlist[noptlist++]),"NETLEBUF");
  10002. #endif /* NETLEBUF */
  10003. #ifdef IKS_OPTION
  10004. makestr(&(optlist[noptlist++]),"IKS_OPTION");
  10005. #endif /* IKS_OPTION */
  10006. #ifdef IKSDB
  10007. makestr(&(optlist[noptlist++]),"IKSDB");
  10008. #endif /* IKSDB */
  10009. #ifdef IKSDCONF
  10010. makestr(&(optlist[noptlist++]),"IKSDCONF");
  10011. #endif /* IKSDCONF */
  10012. #ifdef CK_LOGIN
  10013. makestr(&(optlist[noptlist++]),"CK_LOGIN");
  10014. #endif /* CK_LOGIN */
  10015. #ifdef CK_PAM
  10016. makestr(&(optlist[noptlist++]),"CK_PAM");
  10017. #endif /* CK_PAM */
  10018. #ifdef CK_SHADOW
  10019. makestr(&(optlist[noptlist++]),"CK_SHADOW");
  10020. #endif /* CK_SHADOW */
  10021. #ifdef CONGSPD
  10022. makestr(&(optlist[noptlist++]),"CONGSPD");
  10023. #endif /* CONGSPD */
  10024. #ifdef SUNX25
  10025. makestr(&(optlist[noptlist++]),"SUNX25");
  10026. #endif /* SUNX25 */
  10027. #ifdef IBMX25
  10028. makestr(&(optlist[noptlist++]),"IBMX25");
  10029. #endif /* IBMX25 */
  10030. #ifdef HPX25
  10031. makestr(&(optlist[noptlist++]),"HPX25");
  10032. #endif /* HPX25 */
  10033. #ifdef DECNET
  10034. makestr(&(optlist[noptlist++]),"DECNET");
  10035. #endif /* DECNET */
  10036. #ifdef SUPERLAT
  10037. makestr(&(optlist[noptlist++]),"SUPERLAT");
  10038. #endif /* SUPERLAT */
  10039. #ifdef NPIPE
  10040. makestr(&(optlist[noptlist++]),"NPIPE");
  10041. #endif /* NPIPE */
  10042. #ifdef CK_NETBIOS
  10043. makestr(&(optlist[noptlist++]),"CK_NETBIOS");
  10044. #endif /* CK_NETBIOS */
  10045. #ifdef ATT7300
  10046. makestr(&(optlist[noptlist++]),"ATT7300");
  10047. #endif /* ATT7300 */
  10048. #ifdef ATT6300
  10049. makestr(&(optlist[noptlist++]),"ATT6300");
  10050. #endif /* ATT6300 */
  10051. #ifdef HDBUUCP
  10052. makestr(&(optlist[noptlist++]),"HDBUUCP");
  10053. #endif /* HDBUUCP */
  10054. #ifdef USETTYLOCK
  10055. makestr(&(optlist[noptlist++]),"USETTYLOCK");
  10056. #endif /* USETTYLOCK */
  10057. #ifdef USE_UU_LOCK
  10058. makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
  10059. #endif /* USE_UU_LOCK */
  10060. #ifdef HAVE_LOCKDEV
  10061. makestr(&(optlist[noptlist++]),"HAVE_LOCKDEV");
  10062. #endif /* HAVE_LOCKDEV */
  10063. #ifdef HAVE_BAUDBOY
  10064. makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
  10065. #endif /* HAVE_BAUDBOY */
  10066. #ifdef HAVE_OPENPTY
  10067. makestr(&(optlist[noptlist++]),"HAVE_OPENPTY");
  10068. #endif /* HAVE_OPENPTY */
  10069. #ifdef TTPTYCMD
  10070. makestr(&(optlist[noptlist++]),"TTPTYCMD");
  10071. #endif /* TTPTYCMD */
  10072. #ifdef NOUUCP
  10073. makestr(&(optlist[noptlist++]),"NOUUCP");
  10074. #endif /* NOUUCP */
  10075. #ifdef LONGFN
  10076. makestr(&(optlist[noptlist++]),"LONGFN");
  10077. #endif /* LONGFN */
  10078. #ifdef RDCHK
  10079. makestr(&(optlist[noptlist++]),"RDCHK");
  10080. #endif /* RDCHK */
  10081. #ifdef SELECT
  10082. makestr(&(optlist[noptlist++]),"SELECT");
  10083. #endif /* SELECT */
  10084. #ifdef USLEEP
  10085. makestr(&(optlist[noptlist++]),"USLEEP");
  10086. #endif /* USLEEP */
  10087. #ifdef NAP
  10088. makestr(&(optlist[noptlist++]),"NAP");
  10089. #endif /* NAP */
  10090. #ifdef NAPHACK
  10091. makestr(&(optlist[noptlist++]),"NAPHACK");
  10092. #endif /* NAPHACK */
  10093. #ifdef CK_POLL
  10094. makestr(&(optlist[noptlist++]),"CK_POLL");
  10095. #endif /* CK_POLL */
  10096. #ifdef NOIEXTEN
  10097. makestr(&(optlist[noptlist++]),"NOIEXTEN");
  10098. #endif /* NOIEXTEN */
  10099. #ifdef EXCELAN
  10100. makestr(&(optlist[noptlist++]),"EXCELAN");
  10101. #endif /* EXCELAN */
  10102. #ifdef INTERLAN
  10103. makestr(&(optlist[noptlist++]),"INTERLAN");
  10104. #endif /* INTERLAN */
  10105. #ifdef NOFILEH
  10106. makestr(&(optlist[noptlist++]),"NOFILEH");
  10107. #endif /* NOFILEH */
  10108. #ifdef NOSYSIOCTLH
  10109. makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
  10110. #endif /* NOSYSIOCTLH */
  10111. #ifdef DCLPOPEN
  10112. makestr(&(optlist[noptlist++]),"DCLPOPEN");
  10113. #endif /* DCLPOPEN */
  10114. #ifdef NOSETBUF
  10115. makestr(&(optlist[noptlist++]),"NOSETBUF");
  10116. #endif /* NOSETBUF */
  10117. #ifdef NOXFER
  10118. makestr(&(optlist[noptlist++]),"NOXFER");
  10119. #endif /* NOXFER */
  10120. #ifdef NOCURSES
  10121. makestr(&(optlist[noptlist++]),"NOCURSES");
  10122. #endif /* NOCURSES */
  10123. #ifdef NOSERVER
  10124. makestr(&(optlist[noptlist++]),"NOSERVER");
  10125. #endif /* NOSERVER */
  10126. #ifdef NOPATTERNS
  10127. makestr(&(optlist[noptlist++]),"NOPATTERNS");
  10128. #else
  10129. #ifdef PATTERNS
  10130. makestr(&(optlist[noptlist++]),"PATTERNS");
  10131. #endif /* PATTERNS */
  10132. #endif /* NOPATTERNS */
  10133. #ifdef NOCKEXEC
  10134. makestr(&(optlist[noptlist++]),"NOCKEXEC");
  10135. #else
  10136. #ifdef CKEXEC
  10137. makestr(&(optlist[noptlist++]),"CKEXEC");
  10138. #endif /* CKEXEC */
  10139. #endif /* NOCKEXEC */
  10140. #ifdef NOAUTODL
  10141. makestr(&(optlist[noptlist++]),"NOAUTODL");
  10142. #endif /* NOAUTODL */
  10143. #ifdef NOMSEND
  10144. makestr(&(optlist[noptlist++]),"NOMSEND");
  10145. #endif /* NOMSEND */
  10146. #ifdef NOFDZERO
  10147. makestr(&(optlist[noptlist++]),"NOFDZERO");
  10148. #endif /* NOFDZERO */
  10149. #ifdef NOPOPEN
  10150. makestr(&(optlist[noptlist++]),"NOPOPEN");
  10151. #endif /* NOPOPEN */
  10152. #ifdef NOPARTIAL
  10153. makestr(&(optlist[noptlist++]),"NOPARTIAL");
  10154. #endif /* NOPARTIAL */
  10155. #ifdef NOKVERBS
  10156. makestr(&(optlist[noptlist++]),"NOKVERBS");
  10157. #endif /* NOKVERBS */
  10158. #ifdef NOSETREU
  10159. makestr(&(optlist[noptlist++]),"NOSETREU");
  10160. #endif /* NOSETREU */
  10161. #ifdef LCKDIR
  10162. makestr(&(optlist[noptlist++]),"LCKDIR");
  10163. #endif /* LCKDIR */
  10164. #ifdef ACUCNTRL
  10165. makestr(&(optlist[noptlist++]),"ACUCNTRL");
  10166. #endif /* ACUCNTRL */
  10167. #ifdef BSD4
  10168. makestr(&(optlist[noptlist++]),"BSD4");
  10169. #endif /* BSD4 */
  10170. #ifdef BSD44
  10171. makestr(&(optlist[noptlist++]),"BSD44");
  10172. #endif /* BSD44 */
  10173. #ifdef BSD41
  10174. makestr(&(optlist[noptlist++]),"BSD41");
  10175. #endif /* BSD41 */
  10176. #ifdef BSD43
  10177. makestr(&(optlist[noptlist++]),"BSD43");
  10178. #endif /* BSD43 */
  10179. #ifdef BSD29
  10180. makestr(&(optlist[noptlist++]),"BSD29");
  10181. #endif /* BSD29 */
  10182. #ifdef BSDI
  10183. makestr(&(optlist[noptlist++]),"BSDI");
  10184. #endif /* BSDI */
  10185. #ifdef __bsdi__
  10186. makestr(&(optlist[noptlist++]),"__bsdi__");
  10187. #endif /* __bsdi__ */
  10188. #ifdef __NetBSD__
  10189. makestr(&(optlist[noptlist++]),"__NetBSD__");
  10190. #endif /* __NetBSD__ */
  10191. #ifdef __OpenBSD__
  10192. makestr(&(optlist[noptlist++]),"__OpenBSD__");
  10193. #endif /* __OpenBSD__ */
  10194. #ifdef __FreeBSD__
  10195. makestr(&(optlist[noptlist++]),"__FreeBSD__");
  10196. #endif /* __FreeBSD__ */
  10197. #ifdef FREEBSD4
  10198. makestr(&(optlist[noptlist++]),"FREEBSD4");
  10199. #endif /* FREEBSD4 */
  10200. #ifdef FREEBSD8
  10201. makestr(&(optlist[noptlist++]),"FREEBSD8");
  10202. #endif /* FREEBSD8 */
  10203. #ifdef FREEBSD9
  10204. makestr(&(optlist[noptlist++]),"FREEBSD9");
  10205. #endif /* FREEBSD9 */
  10206. #ifdef __linux__
  10207. makestr(&(optlist[noptlist++]),"__linux__");
  10208. #endif /* __linux__ */
  10209. #ifdef LINUX_HI_SPD
  10210. makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
  10211. #endif /* LINUX_HI_SPD */
  10212. #ifdef LYNXOS
  10213. makestr(&(optlist[noptlist++]),"LYNXOS");
  10214. #endif /* LYNXOS */
  10215. #ifdef V7
  10216. makestr(&(optlist[noptlist++]),"V7");
  10217. #endif /* V7 */
  10218. #ifdef AIX370
  10219. makestr(&(optlist[noptlist++]),"AIX370");
  10220. #endif /* AIX370 */
  10221. #ifdef RTAIX
  10222. makestr(&(optlist[noptlist++]),"RTAIX");
  10223. #endif /* RTAIX */
  10224. #ifdef HPUX
  10225. makestr(&(optlist[noptlist++]),"HPUX");
  10226. #endif /* HPUX */
  10227. #ifdef HPUX9
  10228. makestr(&(optlist[noptlist++]),"HPUX9");
  10229. #endif /* HPUX9 */
  10230. #ifdef HPUX10
  10231. makestr(&(optlist[noptlist++]),"HPUX10");
  10232. #endif /* HPUX10 */
  10233. #ifdef HPUX1000
  10234. makestr(&(optlist[noptlist++]),"HPUX1000");
  10235. #endif /* HPUX1000 */
  10236. #ifdef HPUX1100
  10237. makestr(&(optlist[noptlist++]),"HPUX1100");
  10238. #endif /* HPUX1100 */
  10239. #ifdef HPUXPRE65
  10240. makestr(&(optlist[noptlist++]),"HPUXPRE65");
  10241. #endif /* HPUXPRE65 */
  10242. #ifdef DGUX
  10243. makestr(&(optlist[noptlist++]),"DGUX");
  10244. #endif /* DGUX */
  10245. #ifdef DGUX430
  10246. makestr(&(optlist[noptlist++]),"DGUX430");
  10247. #endif /* DGUX430 */
  10248. #ifdef DGUX540
  10249. makestr(&(optlist[noptlist++]),"DGUX540");
  10250. #endif /* DGUX540 */
  10251. #ifdef DGUX543
  10252. makestr(&(optlist[noptlist++]),"DGUX543");
  10253. #endif /* DGUX543 */
  10254. #ifdef DGUX54410
  10255. makestr(&(optlist[noptlist++]),"DGUX54410");
  10256. #endif /* DGUX54410 */
  10257. #ifdef DGUX54411
  10258. makestr(&(optlist[noptlist++]),"DGUX54411");
  10259. #endif /* DGUX54411 */
  10260. #ifdef sony_news
  10261. makestr(&(optlist[noptlist++]),"sony_news");
  10262. #endif /* sony_news */
  10263. #ifdef CIE
  10264. makestr(&(optlist[noptlist++]),"CIE");
  10265. #endif /* CIE */
  10266. #ifdef XENIX
  10267. makestr(&(optlist[noptlist++]),"XENIX");
  10268. #endif /* XENIX */
  10269. #ifdef SCO_XENIX
  10270. makestr(&(optlist[noptlist++]),"SCO_XENIX");
  10271. #endif /* SCO_XENIX */
  10272. #ifdef ISIII
  10273. makestr(&(optlist[noptlist++]),"ISIII");
  10274. #endif /* ISIII */
  10275. #ifdef I386IX
  10276. makestr(&(optlist[noptlist++]),"I386IX");
  10277. #endif /* I386IX */
  10278. #ifdef RTU
  10279. makestr(&(optlist[noptlist++]),"RTU");
  10280. #endif /* RTU */
  10281. #ifdef PROVX1
  10282. makestr(&(optlist[noptlist++]),"PROVX1");
  10283. #endif /* PROVX1 */
  10284. #ifdef PYRAMID
  10285. makestr(&(optlist[noptlist++]),"PYRAMID");
  10286. #endif /* PYRAMID */
  10287. #ifdef TOWER1
  10288. makestr(&(optlist[noptlist++]),"TOWER1");
  10289. #endif /* TOWER1 */
  10290. #ifdef UTEK
  10291. makestr(&(optlist[noptlist++]),"UTEK");
  10292. #endif /* UTEK */
  10293. #ifdef ZILOG
  10294. makestr(&(optlist[noptlist++]),"ZILOG");
  10295. #endif /* ZILOG */
  10296. #ifdef TRS16
  10297. makestr(&(optlist[noptlist++]),"TRS16");
  10298. #endif /* TRS16 */
  10299. #ifdef MINIX
  10300. makestr(&(optlist[noptlist++]),"MINIX");
  10301. #endif /* MINIX */
  10302. #ifdef MINIX2
  10303. makestr(&(optlist[noptlist++]),"MINIX2");
  10304. #endif /* MINIX2 */
  10305. #ifdef MINIX3
  10306. makestr(&(optlist[noptlist++]),"MINIX3");
  10307. #endif /* MINIX3 */
  10308. #ifdef MINIX315
  10309. makestr(&(optlist[noptlist++]),"MINIX315");
  10310. #endif /* MINIX315 */
  10311. #ifdef C70
  10312. makestr(&(optlist[noptlist++]),"C70");
  10313. #endif /* C70 */
  10314. #ifdef AIXPS2
  10315. makestr(&(optlist[noptlist++]),"AIXPS2");
  10316. #endif /* AIXPS2 */
  10317. #ifdef AIXRS
  10318. makestr(&(optlist[noptlist++]),"AIXRS");
  10319. #endif /* AIXRS */
  10320. #ifdef UTSV
  10321. makestr(&(optlist[noptlist++]),"UTSV");
  10322. #endif /* UTSV */
  10323. #ifdef ATTSV
  10324. makestr(&(optlist[noptlist++]),"ATTSV");
  10325. #endif /* ATTSV */
  10326. #ifdef SVR3
  10327. makestr(&(optlist[noptlist++]),"SVR3");
  10328. #endif /* SVR3 */
  10329. #ifdef SVR4
  10330. makestr(&(optlist[noptlist++]),"SVR4");
  10331. #endif /* SVR4 */
  10332. #ifdef DELL_SVR4
  10333. makestr(&(optlist[noptlist++]),"DELL_SVR4");
  10334. #endif /* DELL_SVR4 */
  10335. #ifdef ICL_SVR4
  10336. makestr(&(optlist[noptlist++]),"ICL_SVR4");
  10337. #endif /* ICL_SVR4 */
  10338. #ifdef OSF
  10339. makestr(&(optlist[noptlist++]),"OSF");
  10340. #endif /* OSF */
  10341. #ifdef OSF1
  10342. makestr(&(optlist[noptlist++]),"OSF1");
  10343. #endif /* OSF1 */
  10344. #ifdef __OSF
  10345. makestr(&(optlist[noptlist++]),"__OSF");
  10346. #endif /* __OSF */
  10347. #ifdef __OSF__
  10348. makestr(&(optlist[noptlist++]),"__OSF__");
  10349. #endif /* __OSF__ */
  10350. #ifdef __osf__
  10351. makestr(&(optlist[noptlist++]),"__osf__");
  10352. #endif /* __osf__ */
  10353. #ifdef __OSF1
  10354. makestr(&(optlist[noptlist++]),"__OSF1");
  10355. #endif /* __OSF1 */
  10356. #ifdef __OSF1__
  10357. makestr(&(optlist[noptlist++]),"__OSF1__");
  10358. #endif /* __OSF1__ */
  10359. #ifdef PTX
  10360. makestr(&(optlist[noptlist++]),"PTX");
  10361. #endif /* PTX */
  10362. #ifdef POSIX
  10363. makestr(&(optlist[noptlist++]),"POSIX");
  10364. #endif /* POSIX */
  10365. #ifdef BSD44ORPOSIX
  10366. makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
  10367. #endif /* BSD44ORPOSIX */
  10368. #ifdef SVORPOSIX
  10369. makestr(&(optlist[noptlist++]),"SVORPOSIX");
  10370. #endif /* SVORPOSIX */
  10371. #ifdef SVR4ORPOSIX
  10372. makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
  10373. #endif /* SVR4ORPOSIX */
  10374. #ifdef OS2ORVMS
  10375. makestr(&(optlist[noptlist++]),"OS2ORVMS");
  10376. #endif /* OS2ORVMS */
  10377. #ifdef OS2ORUNIX
  10378. makestr(&(optlist[noptlist++]),"OS2ORUNIX");
  10379. #endif /* OS2ORUNIX */
  10380. #ifdef VMSORUNIX
  10381. makestr(&(optlist[noptlist++]),"VMSORUNIX");
  10382. #endif /* VMSORUNIX */
  10383. #ifdef VMS64BIT
  10384. makestr(&(optlist[noptlist++]),"VMS64BIT"); /* VMS on Alpha or IA64 */
  10385. #endif /* VMS64BIT */
  10386. #ifdef VMSI64
  10387. makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
  10388. #endif /* VMSI64 */
  10389. #ifdef _POSIX_SOURCE
  10390. makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
  10391. #endif /* _POSIX_SOURCE */
  10392. #ifdef _XOPEN_SOURCE
  10393. makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
  10394. #endif
  10395. #ifdef _ALL_SOURCE
  10396. makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
  10397. #endif
  10398. #ifdef _SVID3
  10399. makestr(&(optlist[noptlist++]),"_SVID3");
  10400. #endif /* _SVID3 */
  10401. #ifdef Plan9
  10402. makestr(&(optlist[noptlist++]),"Plan9");
  10403. #endif /* Plan9 */
  10404. #ifdef SOLARIS
  10405. makestr(&(optlist[noptlist++]),"SOLARIS");
  10406. #ifdef SOLARIS24
  10407. makestr(&(optlist[noptlist++]),"SOLARIS24");
  10408. #endif /* SOLARIS24 */
  10409. #ifdef SOLARIS25
  10410. makestr(&(optlist[noptlist++]),"SOLARIS25");
  10411. #endif /* SOLARIS25 */
  10412. #ifdef SOLARIS26
  10413. makestr(&(optlist[noptlist++]),"SOLARIS26");
  10414. #endif /* SOLARIS26 */
  10415. #ifdef SOLARIS7
  10416. makestr(&(optlist[noptlist++]),"SOLARIS7");
  10417. #endif /* SOLARIS7 */
  10418. #ifdef SOLARIS8
  10419. makestr(&(optlist[noptlist++]),"SOLARIS8");
  10420. #endif /* SOLARIS8 */
  10421. #ifdef SOLARIS9
  10422. makestr(&(optlist[noptlist++]),"SOLARIS9");
  10423. #endif /* SOLARIS9 */
  10424. #ifdef SOLARIS10
  10425. makestr(&(optlist[noptlist++]),"SOLARIS10");
  10426. #endif /* SOLARIS10 */
  10427. #endif /* SOLARIS */
  10428. #ifdef SUNOS4
  10429. makestr(&(optlist[noptlist++]),"SUNOS4");
  10430. #endif /* SUNOS4 */
  10431. #ifdef SUN4S5
  10432. makestr(&(optlist[noptlist++]),"SUN4S5");
  10433. #endif /* SUN4S5 */
  10434. #ifdef IRIX
  10435. makestr(&(optlist[noptlist++]),"IRIX");
  10436. #endif /* IRIX */
  10437. #ifdef ENCORE
  10438. makestr(&(optlist[noptlist++]),"ENCORE");
  10439. #endif /* ENCORE */
  10440. #ifdef ultrix
  10441. makestr(&(optlist[noptlist++]),"ultrix");
  10442. #endif
  10443. #ifdef sxaE50
  10444. makestr(&(optlist[noptlist++]),"sxaE50");
  10445. #endif
  10446. #ifdef mips
  10447. makestr(&(optlist[noptlist++]),"mips");
  10448. #endif
  10449. #ifdef MIPS
  10450. makestr(&(optlist[noptlist++]),"MIPS");
  10451. #endif
  10452. #ifdef vax
  10453. makestr(&(optlist[noptlist++]),"vax");
  10454. #endif
  10455. #ifdef VAX
  10456. makestr(&(optlist[noptlist++]),"VAX");
  10457. #endif
  10458. #ifdef alpha
  10459. makestr(&(optlist[noptlist++]),"alpha");
  10460. #endif
  10461. #ifdef ALPHA
  10462. makestr(&(optlist[noptlist++]),"ALPHA");
  10463. #endif
  10464. #ifdef __ALPHA
  10465. makestr(&(optlist[noptlist++]),"__ALPHA");
  10466. #endif
  10467. #ifdef __alpha
  10468. makestr(&(optlist[noptlist++]),"__alpha");
  10469. #endif
  10470. #ifdef __AXP
  10471. makestr(&(optlist[noptlist++]),"__AXP");
  10472. #endif
  10473. #ifdef AXP
  10474. makestr(&(optlist[noptlist++]),"AXP");
  10475. #endif
  10476. #ifdef axp
  10477. makestr(&(optlist[noptlist++]),"axp");
  10478. #endif
  10479. #ifdef __ALPHA__
  10480. makestr(&(optlist[noptlist++]),"__ALPHA__");
  10481. #endif
  10482. #ifdef __alpha__
  10483. makestr(&(optlist[noptlist++]),"__alpha__");
  10484. #endif
  10485. #ifdef sun
  10486. makestr(&(optlist[noptlist++]),"sun");
  10487. #endif
  10488. #ifdef sun3
  10489. makestr(&(optlist[noptlist++]),"sun3");
  10490. #endif
  10491. #ifdef sun386
  10492. makestr(&(optlist[noptlist++]),"sun386");
  10493. #endif
  10494. #ifdef _SUN
  10495. makestr(&(optlist[noptlist++]),"_SUN");
  10496. #endif
  10497. #ifdef sun4
  10498. makestr(&(optlist[noptlist++]),"sun4");
  10499. #endif
  10500. #ifdef sparc
  10501. makestr(&(optlist[noptlist++]),"sparc");
  10502. #endif
  10503. #ifdef _CRAY
  10504. makestr(&(optlist[noptlist++]),"_CRAY");
  10505. #endif /* _CRAY */
  10506. #ifdef NEXT33
  10507. makestr(&(optlist[noptlist++]),"NEXT33");
  10508. #endif
  10509. #ifdef NEXT
  10510. makestr(&(optlist[noptlist++]),"NEXT");
  10511. #endif
  10512. #ifdef NeXT
  10513. makestr(&(optlist[noptlist++]),"NeXT");
  10514. #endif
  10515. #ifdef MACH
  10516. makestr(&(optlist[noptlist++]),"MACH");
  10517. #endif
  10518. #ifdef MACOSX
  10519. makestr(&(optlist[noptlist++]),"MACOSX");
  10520. #endif
  10521. #ifdef MACOSX10
  10522. makestr(&(optlist[noptlist++]),"MACOSX10");
  10523. #endif
  10524. #ifdef MACOSX103
  10525. makestr(&(optlist[noptlist++]),"MACOSX10e");
  10526. #endif
  10527. #ifdef COMMENT
  10528. /* not used */
  10529. #ifdef MACOSX103
  10530. makestr(&(optlist[noptlist++]),"MACOSX103");
  10531. #endif
  10532. #endif /* COMMENT */
  10533. #ifdef sgi
  10534. makestr(&(optlist[noptlist++]),"sgi");
  10535. #endif
  10536. #ifdef M_SYS5
  10537. makestr(&(optlist[noptlist++]),"M_SYS5");
  10538. #endif
  10539. #ifdef __SYSTEM_FIVE
  10540. makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
  10541. #endif
  10542. #ifdef sysV
  10543. makestr(&(optlist[noptlist++]),"sysV");
  10544. #endif
  10545. #ifdef M_XENIX /* SCO Xenix V and UNIX/386 */
  10546. makestr(&(optlist[noptlist++]),"M_XENIX");
  10547. #endif
  10548. #ifdef M_UNIX /* SCO UNIX */
  10549. makestr(&(optlist[noptlist++]),"M_UNIX");
  10550. #endif
  10551. #ifdef _M_UNIX /* SCO UNIX 3.2v4 = ODT 2.0 */
  10552. makestr(&(optlist[noptlist++]),"_M_UNIX");
  10553. #endif
  10554. #ifdef CK_SCOV5
  10555. makestr(&(optlist[noptlist++]),"CK_SCOV5");
  10556. #endif
  10557. #ifdef SCO_OSR504
  10558. makestr(&(optlist[noptlist++]),"SCO_OSR504");
  10559. #endif
  10560. #ifdef M_IA64
  10561. makestr(&(optlist[noptlist++]),"M_IA64");
  10562. #endif
  10563. #ifdef _M_IA64
  10564. makestr(&(optlist[noptlist++]),"_M_IA64");
  10565. #endif
  10566. #ifdef ia64
  10567. makestr(&(optlist[noptlist++]),"ia64");
  10568. #endif
  10569. #ifdef _ia64
  10570. makestr(&(optlist[noptlist++]),"_ia64");
  10571. #endif
  10572. #ifdef _ia64_
  10573. makestr(&(optlist[noptlist++]),"_ia64_");
  10574. #endif
  10575. #ifdef __ia64
  10576. makestr(&(optlist[noptlist++]),"__ia64");
  10577. #endif
  10578. #ifdef M_I686
  10579. makestr(&(optlist[noptlist++]),"M_I686");
  10580. #endif
  10581. #ifdef _M_I686
  10582. makestr(&(optlist[noptlist++]),"_M_I686");
  10583. #endif
  10584. #ifdef i686
  10585. makestr(&(optlist[noptlist++]),"i686");
  10586. #endif
  10587. #ifdef M_I586
  10588. makestr(&(optlist[noptlist++]),"M_I586");
  10589. #endif
  10590. #ifdef _M_I586
  10591. makestr(&(optlist[noptlist++]),"_M_I586");
  10592. #endif
  10593. #ifdef i586
  10594. makestr(&(optlist[noptlist++]),"i586");
  10595. #endif
  10596. #ifdef M_I486
  10597. makestr(&(optlist[noptlist++]),"M_I486");
  10598. #endif
  10599. #ifdef _M_I486
  10600. makestr(&(optlist[noptlist++]),"_M_I486");
  10601. #endif
  10602. #ifdef i486
  10603. makestr(&(optlist[noptlist++]),"i486");
  10604. #endif
  10605. #ifdef M_I386
  10606. makestr(&(optlist[noptlist++]),"M_I386");
  10607. #endif
  10608. #ifdef _M_I386
  10609. makestr(&(optlist[noptlist++]),"_M_I386");
  10610. #endif
  10611. #ifdef i386
  10612. makestr(&(optlist[noptlist++]),"i386");
  10613. #endif
  10614. #ifdef __i386
  10615. makestr(&(optlist[noptlist++]),"__i386");
  10616. #endif
  10617. #ifdef __x86
  10618. makestr(&(optlist[noptlist++]),"__x86");
  10619. #endif
  10620. #ifdef __x86_64
  10621. makestr(&(optlist[noptlist++]),"__x86_64");
  10622. #endif
  10623. #ifdef __amd64
  10624. makestr(&(optlist[noptlist++]),"__amd64");
  10625. #endif
  10626. #ifdef _ILP32
  10627. makestr(&(optlist[noptlist++]),"_ILP32");
  10628. #endif
  10629. #ifdef _ILP64
  10630. makestr(&(optlist[noptlist++]),"_ILP64");
  10631. #endif
  10632. #ifdef _LP32
  10633. makestr(&(optlist[noptlist++]),"_LP32");
  10634. #endif
  10635. #ifdef _LP64
  10636. makestr(&(optlist[noptlist++]),"_LP64");
  10637. #endif
  10638. #ifdef __LP32__
  10639. makestr(&(optlist[noptlist++]),"__LP32__");
  10640. #endif
  10641. #ifdef __LP64__
  10642. makestr(&(optlist[noptlist++]),"__LP64__");
  10643. #endif
  10644. #ifdef _XGP4_2
  10645. makestr(&(optlist[noptlist++]),"_XGP4_2");
  10646. #endif
  10647. #ifdef __ppc__
  10648. makestr(&(optlist[noptlist++]),"__ppc__");
  10649. #endif
  10650. #ifdef __ppc32__
  10651. makestr(&(optlist[noptlist++]),"__ppc32__");
  10652. #endif
  10653. #ifdef __ppc64__
  10654. makestr(&(optlist[noptlist++]),"__ppc64__");
  10655. #endif
  10656. #ifdef CK_64BIT
  10657. makestr(&(optlist[noptlist++]),"CK_64BIT");
  10658. #endif
  10659. #ifdef i286
  10660. makestr(&(optlist[noptlist++]),"i286");
  10661. #endif
  10662. #ifdef M_I286
  10663. makestr(&(optlist[noptlist++]),"M_I286");
  10664. #endif
  10665. #ifdef __sparc
  10666. makestr(&(optlist[noptlist++]),"__sparc");
  10667. #endif
  10668. #ifdef __sparcv8
  10669. makestr(&(optlist[noptlist++]),"__sparcv8");
  10670. #endif
  10671. #ifdef __sparcv9
  10672. makestr(&(optlist[noptlist++]),"__sparcv9");
  10673. #endif
  10674. #ifdef mc68000
  10675. makestr(&(optlist[noptlist++]),"mc68000");
  10676. #endif
  10677. #ifdef mc68010
  10678. makestr(&(optlist[noptlist++]),"mc68010");
  10679. #endif
  10680. #ifdef mc68020
  10681. makestr(&(optlist[noptlist++]),"mc68020");
  10682. #endif
  10683. #ifdef mc68030
  10684. makestr(&(optlist[noptlist++]),"mc68030");
  10685. #endif
  10686. #ifdef mc68040
  10687. makestr(&(optlist[noptlist++]),"mc68040");
  10688. #endif
  10689. #ifdef M_68000
  10690. makestr(&(optlist[noptlist++]),"M_68000");
  10691. #endif
  10692. #ifdef M_68010
  10693. makestr(&(optlist[noptlist++]),"M_68010");
  10694. #endif
  10695. #ifdef M_68020
  10696. makestr(&(optlist[noptlist++]),"M_68020");
  10697. #endif
  10698. #ifdef M_68030
  10699. makestr(&(optlist[noptlist++]),"M_68030");
  10700. #endif
  10701. #ifdef M_68040
  10702. makestr(&(optlist[noptlist++]),"M_68040");
  10703. #endif
  10704. #ifdef m68k
  10705. makestr(&(optlist[noptlist++]),"m68k");
  10706. #endif
  10707. #ifdef m88k
  10708. makestr(&(optlist[noptlist++]),"m88k");
  10709. #endif
  10710. #ifdef pdp11
  10711. makestr(&(optlist[noptlist++]),"pdp11");
  10712. #endif
  10713. #ifdef iAPX
  10714. makestr(&(optlist[noptlist++]),"iAPX");
  10715. #endif
  10716. #ifdef hpux
  10717. makestr(&(optlist[noptlist++]),"hpux");
  10718. #endif
  10719. #ifdef __hpux
  10720. makestr(&(optlist[noptlist++]),"__hpux");
  10721. #endif
  10722. #ifdef __hp9000s800
  10723. makestr(&(optlist[noptlist++]),"__hp9000s800");
  10724. #endif
  10725. #ifdef __hp9000s700
  10726. makestr(&(optlist[noptlist++]),"__hp9000s700");
  10727. #endif
  10728. #ifdef __hp9000s500
  10729. makestr(&(optlist[noptlist++]),"__hp9000s500");
  10730. #endif
  10731. #ifdef __hp9000s300
  10732. makestr(&(optlist[noptlist++]),"__hp9000s300");
  10733. #endif
  10734. #ifdef __hp9000s200
  10735. makestr(&(optlist[noptlist++]),"__hp9000s200");
  10736. #endif
  10737. #ifdef AIX
  10738. makestr(&(optlist[noptlist++]),"AIX");
  10739. #endif
  10740. #ifdef _AIXFS
  10741. makestr(&(optlist[noptlist++]),"_AIXFS");
  10742. #endif
  10743. #ifdef u370
  10744. makestr(&(optlist[noptlist++]),"u370");
  10745. #endif
  10746. #ifdef u3b
  10747. makestr(&(optlist[noptlist++]),"u3b");
  10748. #endif
  10749. #ifdef u3b2
  10750. makestr(&(optlist[noptlist++]),"u3b2");
  10751. #endif
  10752. #ifdef multimax
  10753. makestr(&(optlist[noptlist++]),"multimax");
  10754. #endif
  10755. #ifdef balance
  10756. makestr(&(optlist[noptlist++]),"balance");
  10757. #endif
  10758. #ifdef ibmrt
  10759. makestr(&(optlist[noptlist++]),"ibmrt");
  10760. #endif
  10761. #ifdef _IBMRT
  10762. makestr(&(optlist[noptlist++]),"_IBMRT");
  10763. #endif
  10764. #ifdef ibmrs6000
  10765. makestr(&(optlist[noptlist++]),"ibmrs6000");
  10766. #endif
  10767. #ifdef _AIX
  10768. makestr(&(optlist[noptlist++]),"_AIX");
  10769. #endif /* _AIX */
  10770. #ifdef _IBMR2
  10771. makestr(&(optlist[noptlist++]),"_IBMR2");
  10772. #endif
  10773. #ifdef UNIXWARE
  10774. makestr(&(optlist[noptlist++]),"UNIXWARE");
  10775. #endif
  10776. #ifdef QNX
  10777. makestr(&(optlist[noptlist++]),"QNX");
  10778. #ifdef __QNX__
  10779. makestr(&(optlist[noptlist++]),"__QNX__");
  10780. #ifdef __16BIT__
  10781. makestr(&(optlist[noptlist++]),"__16BIT__");
  10782. #endif
  10783. #ifdef CK_QNX16
  10784. makestr(&(optlist[noptlist++]),"CK_QNX16");
  10785. #endif
  10786. #ifdef __32BIT__
  10787. makestr(&(optlist[noptlist++]),"__32BIT__");
  10788. #endif
  10789. #ifdef CK_QNX32
  10790. makestr(&(optlist[noptlist++]),"CK_QNX32");
  10791. #endif
  10792. #endif /* __QNX__ */
  10793. #endif /* QNX */
  10794. #ifdef QNX6
  10795. makestr(&(optlist[noptlist++]),"QNX6");
  10796. #endif /* QNX6 */
  10797. #ifdef NEUTRINO
  10798. makestr(&(optlist[noptlist++]),"NEUTRINO");
  10799. #endif /* NEUTRINO */
  10800. #ifdef __STRICT_BSD__
  10801. makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
  10802. #endif
  10803. #ifdef __STRICT_ANSI__
  10804. makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
  10805. #endif
  10806. #ifdef _ANSI_C_SOURCE
  10807. makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
  10808. #endif
  10809. #ifdef __STDC__
  10810. makestr(&(optlist[noptlist++]),"__STDC__");
  10811. #endif
  10812. #ifdef cplusplus
  10813. makestr(&(optlist[noptlist++]),"cplusplus");
  10814. #endif
  10815. #ifdef __DECC
  10816. makestr(&(optlist[noptlist++]),"__DECC");
  10817. #ifdef __DECC_VER
  10818. sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
  10819. makestr(&(optlist[noptlist++]),line);
  10820. #endif /* __DECC_VER */
  10821. #endif /* __DECC */
  10822. #ifdef __CRTL_VER
  10823. sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
  10824. makestr(&(optlist[noptlist++]),line);
  10825. #endif /* __CRTL_VER */
  10826. #ifdef __GNUC__ /* gcc in ansi mode */
  10827. makestr(&(optlist[noptlist++]),"__GNUC__");
  10828. #endif
  10829. #ifdef GNUC /* gcc in traditional mode */
  10830. makestr(&(optlist[noptlist++]),"GNUC");
  10831. #endif
  10832. #ifdef __EGCS__ /* egcs in ansi mode */
  10833. makestr(&(optlist[noptlist++]),"__EGCS__");
  10834. #endif
  10835. #ifdef __egcs__ /* egcs in ansi mode */
  10836. makestr(&(optlist[noptlist++]),"__egcs__");
  10837. #endif
  10838. #ifdef __WATCOMC__
  10839. makestr(&(optlist[noptlist++]),"__WATCOMC__");
  10840. #endif
  10841. #ifdef CK_ANSIC
  10842. makestr(&(optlist[noptlist++]),"CK_ANSIC");
  10843. #endif
  10844. #ifdef CK_ANSILIBS
  10845. makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
  10846. #endif
  10847. #ifdef CKCONINTB4CB
  10848. makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
  10849. #endif /* CKCONINTB4CB */
  10850. #ifdef NOTERMCAP
  10851. makestr(&(optlist[noptlist++]),"NOTERMCAP");
  10852. #endif /* NOTERMCAP */
  10853. #ifdef __GLIBC__
  10854. makestr(&(optlist[noptlist++]),"__GLIBC__");
  10855. #endif
  10856. #ifdef _SC_JOB_CONTROL
  10857. makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
  10858. #endif
  10859. #ifdef _POSIX_JOB_CONTROL
  10860. makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
  10861. #endif
  10862. #ifdef SIG_I
  10863. makestr(&(optlist[noptlist++]),"SIG_I");
  10864. #endif /* SIG_I */
  10865. #ifdef SIG_V
  10866. makestr(&(optlist[noptlist++]),"SIG_V");
  10867. #endif /* SIG_V */
  10868. #ifdef CK_POSIX_SIG
  10869. makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
  10870. #endif
  10871. #ifdef SVR3JC
  10872. makestr(&(optlist[noptlist++]),"SVR3JC");
  10873. #endif
  10874. #ifdef _386BSD
  10875. makestr(&(optlist[noptlist++]),"_386BSD");
  10876. #endif
  10877. #ifdef _BSD
  10878. makestr(&(optlist[noptlist++]),"_BSD");
  10879. #endif
  10880. #ifdef USE_MEMCPY
  10881. makestr(&(optlist[noptlist++]),"USE_MEMCPY");
  10882. #endif /* USE_MEMCPY */
  10883. #ifdef USE_LSTAT
  10884. makestr(&(optlist[noptlist++]),"USE_LSTAT");
  10885. #endif /* USE_LSTAT */
  10886. #ifdef TERMIOX
  10887. makestr(&(optlist[noptlist++]),"TERMIOX");
  10888. #endif /* TERMIOX */
  10889. #ifdef STERMIOX
  10890. makestr(&(optlist[noptlist++]),"STERMIOX");
  10891. #endif /* STERMIOX */
  10892. #ifdef CK_CURSES
  10893. makestr(&(optlist[noptlist++]),"CK_CURSES");
  10894. #endif /* CK_CURSES */
  10895. #ifdef CK_NEWTERM
  10896. makestr(&(optlist[noptlist++]),"CK_NEWTERM");
  10897. #endif /* CK_NEWTERM */
  10898. #ifdef CK_WREFRESH
  10899. makestr(&(optlist[noptlist++]),"CK_WREFRESH");
  10900. #endif /* CK_WREFRESH */
  10901. #ifdef CK_PCT_BAR
  10902. makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
  10903. #endif /* CK_PCT_BAR */
  10904. #ifdef CK_DTRCD
  10905. makestr(&(optlist[noptlist++]),"CK_DTRCD");
  10906. #endif /* CK_DTRCD */
  10907. #ifdef CK_DTRCTS
  10908. makestr(&(optlist[noptlist++]),"CK_DTRCTS");
  10909. #endif /* CK_DTRCTS */
  10910. #ifdef CK_RTSCTS
  10911. makestr(&(optlist[noptlist++]),"CK_RTSCTS");
  10912. #endif /* CK_RTSCTS */
  10913. #ifdef POSIX_CRTSCTS
  10914. makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
  10915. #endif /* POSIX_CRTSCTS */
  10916. #ifdef FIXCRTSCTS
  10917. makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
  10918. #endif /* FIXCRTSCTS */
  10919. #ifdef HWPARITY
  10920. makestr(&(optlist[noptlist++]),"HWPARITY");
  10921. #endif /* HWPARITY */
  10922. #ifdef CK_SYSINI
  10923. #ifdef CK_INI_A
  10924. makestr(&(optlist[noptlist++]),"CK_INI_A");
  10925. ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10926. makestr(&(optlist[noptlist++]),line);
  10927. #else
  10928. #ifdef CK_INI_B
  10929. makestr(&(optlist[noptlist++]),"CK_INI_B");
  10930. ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
  10931. makestr(&(optlist[noptlist++]),line);
  10932. #else
  10933. makestr(&(optlist[noptlist++]),"CK_SYSINI");
  10934. #endif /* CK_INI_B */
  10935. #endif /* CK_INI_A */
  10936. #endif /* CK_DSYSINI */
  10937. #ifdef CK_DSYSINI
  10938. makestr(&(optlist[noptlist++]),"CK_DSYSINI");
  10939. #endif /* CK_DSYSINI */
  10940. #ifdef CK_TTGWSIZ
  10941. makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
  10942. #endif /* CK_TTGWSIZ */
  10943. #ifdef CK_NAWS
  10944. makestr(&(optlist[noptlist++]),"CK_NAWS");
  10945. #endif /* CK_NAWS */
  10946. #ifdef MDMHUP
  10947. makestr(&(optlist[noptlist++]),"MDMHUP");
  10948. #endif /* MDMHUP */
  10949. #ifdef HUP_CLOSE_POSIX
  10950. makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
  10951. #endif /* HUP_CLOSE_POSIX */
  10952. #ifdef NO_HUP_CLOSE_POSIX
  10953. makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
  10954. #endif /* NO_HUP_CLOSE_POSIX */
  10955. #ifdef DCMDBUF
  10956. makestr(&(optlist[noptlist++]),"DCMDBUF");
  10957. #endif /* DCMDBUF */
  10958. #ifdef CK_RECALL
  10959. makestr(&(optlist[noptlist++]),"CK_RECALL");
  10960. #endif /* CK_RECALL */
  10961. #ifdef BROWSER
  10962. makestr(&(optlist[noptlist++]),"BROWSER");
  10963. #endif /* BROWSER */
  10964. #ifdef CLSOPN
  10965. makestr(&(optlist[noptlist++]),"CLSOPN");
  10966. #endif /* CLSOPN */
  10967. #ifdef STRATUS
  10968. makestr(&(optlist[noptlist++]),"STRATUS");
  10969. #endif /* STRATUS */
  10970. #ifdef __VOS__
  10971. makestr(&(optlist[noptlist++]),"__VOS__");
  10972. #endif /* __VOS__ */
  10973. #ifdef STRATUSX25
  10974. makestr(&(optlist[noptlist++]),"STRATUSX25");
  10975. #endif /* STRATUSX25 */
  10976. #ifdef OS2MOUSE
  10977. makestr(&(optlist[noptlist++]),"OS2MOUSE");
  10978. #endif /* OS2MOUSE */
  10979. #ifdef CK_REXX
  10980. makestr(&(optlist[noptlist++]),"CK_REXX");
  10981. #endif /* CK_REXX */
  10982. #ifdef CK_TIMERS
  10983. makestr(&(optlist[noptlist++]),"CK_TIMERS");
  10984. #endif /* CK_TIMERS */
  10985. #ifdef TTSPDLIST
  10986. makestr(&(optlist[noptlist++]),"TTSPDLIST");
  10987. #endif /* TTSPDLIST */
  10988. #ifdef CK_PERMS
  10989. makestr(&(optlist[noptlist++]),"CK_PERMS");
  10990. #endif /* CK_PERMS */
  10991. #ifdef CKTUNING
  10992. makestr(&(optlist[noptlist++]),"CKTUNING");
  10993. #endif /* CKTUNING */
  10994. #ifdef NEWFTP
  10995. makestr(&(optlist[noptlist++]),"NEWFTP");
  10996. #endif /* NEWFTP */
  10997. #ifdef SYSFTP
  10998. makestr(&(optlist[noptlist++]),"SYSFTP");
  10999. #endif /* SYSFTP */
  11000. #ifdef NOFTP
  11001. makestr(&(optlist[noptlist++]),"NOFTP");
  11002. #endif /* NOFTP */
  11003. #ifdef CKHTTP
  11004. makestr(&(optlist[noptlist++]),"CKHTTP");
  11005. #endif /* CKHTTP */
  11006. #ifdef NOHTTP
  11007. makestr(&(optlist[noptlist++]),"NOHTTP");
  11008. #endif /* NOHTTP */
  11009. #ifdef CKROOT
  11010. makestr(&(optlist[noptlist++]),"CKROOT");
  11011. #endif /* CKROOT */
  11012. #ifdef CKREALPATH
  11013. makestr(&(optlist[noptlist++]),"CKREALPATH");
  11014. #endif /* CKREALPATH */
  11015. #ifdef STREAMING
  11016. makestr(&(optlist[noptlist++]),"STREAMING");
  11017. #endif /* STREAMING */
  11018. #ifdef UNPREFIXZERO
  11019. makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
  11020. #endif /* UNPREFIXZERO */
  11021. #ifdef CKREGEX
  11022. makestr(&(optlist[noptlist++]),"CKREGEX");
  11023. #endif /* CKREGEX */
  11024. #ifdef ZXREWIND
  11025. makestr(&(optlist[noptlist++]),"ZXREWIND");
  11026. #endif /* ZXREWIND */
  11027. #ifdef CKSYSLOG
  11028. makestr(&(optlist[noptlist++]),"CKSYSLOG");
  11029. #endif /* CKSYSLOG */
  11030. #ifdef SYSLOGLEVEL
  11031. sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
  11032. makestr(&(optlist[noptlist++]),line);
  11033. #endif /* SYSLOGLEVEL */
  11034. #ifdef NOSEXP
  11035. makestr(&(optlist[noptlist++]),"NOSEXP");
  11036. #endif /* NOSEXP */
  11037. #ifdef CKLEARN
  11038. makestr(&(optlist[noptlist++]),"CKLEARN");
  11039. #else
  11040. #ifdef NOLOEARN
  11041. makestr(&(optlist[noptlist++]),"NOLOEARN");
  11042. #endif /* NOLOEARN */
  11043. #endif /* CKLEARN */
  11044. #ifdef BETATEST
  11045. makestr(&(optlist[noptlist++]),"BETATEST");
  11046. #endif /* BETATEST */
  11047. #ifdef NOFLOAT
  11048. makestr(&(optlist[noptlist++]),"NOFLOAT");
  11049. #else
  11050. #ifdef FNFLOAT
  11051. makestr(&(optlist[noptlist++]),"FNFLOAT");
  11052. #endif /* FNFLOAT */
  11053. #ifdef CKFLOAT
  11054. #ifdef GFTIMER
  11055. makestr(&(optlist[noptlist++]),"GFTIMER");
  11056. #endif /* GFTIMER */
  11057. #ifdef CKFLOAT_S
  11058. ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
  11059. makestr(&(optlist[noptlist++]),line);
  11060. #else
  11061. makestr(&(optlist[noptlist++]),"CKFLOAT");
  11062. #endif /* CKFLOAT_S */
  11063. #endif /* CKFLOAT */
  11064. #endif /* NOFLOAT */
  11065. #ifdef SSH
  11066. makestr(&(optlist[noptlist++]),"SSH");
  11067. #endif /* SSH */
  11068. #ifdef NETDLL
  11069. makestr(&(optlist[noptlist++]),"NETDLL");
  11070. #endif /* NETDLL */
  11071. #ifdef NETFILE
  11072. makestr(&(optlist[noptlist++]),"NETFILE");
  11073. #endif /* NETFILE */
  11074. #ifdef CK_TAPI
  11075. makestr(&(optlist[noptlist++]),"CK_TAPI");
  11076. #endif /* CK_TAPI */
  11077. #ifdef CK_SSL
  11078. makestr(&(optlist[noptlist++]),"CK_SSL");
  11079. #ifdef OPENSSL_VERSION_TEXT
  11080. ckmakmsg(line,LINBUFSIZ,
  11081. "OPENSSL_VERSION_TEXT=","\"",OPENSSL_VERSION_TEXT,"\"");
  11082. makestr(&(optlist[noptlist++]),line);
  11083. #endif /* OPENSSL_VERSION_TEXT */
  11084. #endif /* CK_SSL */
  11085. debug(F101,"initoptlist noptlist","",noptlist);
  11086. sh_sort(optlist,NULL,noptlist,0,0,0);
  11087. }
  11088. int
  11089. shofea() {
  11090. int i;
  11091. int flag = 0;
  11092. int lines = 1;
  11093. #ifdef FNFLOAT
  11094. extern int fp_digits, fp_rounding;
  11095. #endif /* FNFLOAT */
  11096. extern int byteorder;
  11097. printf("%s\n",versio);
  11098. if (inserver)
  11099. return(1);
  11100. debug(F101,"shofea NOPTLIST","",NOPTLIST);
  11101. initoptlist();
  11102. debug(F101,"shofea noptlist","",noptlist);
  11103. #ifdef OS2
  11104. #ifdef NT
  11105. #ifdef _M_ALPHA
  11106. printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
  11107. #else /* _M_ALPHA */
  11108. #ifdef _M_PPC
  11109. printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
  11110. #else /* _M_PPC */
  11111. #ifdef _M_MRX000
  11112. printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
  11113. #else /* _M_MRX000 */
  11114. #ifdef _M_IX86
  11115. printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
  11116. #else /* _M_IX86 */
  11117. UNKNOWN WINDOWS PLATFORM
  11118. #endif /* _M_IX86 */
  11119. #endif /* _M_MRX000 */
  11120. #endif /* _M_PPC */
  11121. #endif /* _M_ALPHA */
  11122. #else /* NT */
  11123. #ifdef M_I286
  11124. printf("IBM OS/2 16-bit.\n");
  11125. #else
  11126. printf("IBM OS/2 32-bit.\n");
  11127. #endif /* M_I286 */
  11128. #endif /* NT */
  11129. lines++;
  11130. #endif /* OS2 */
  11131. printf("\n");
  11132. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11133. printf("Major optional features included:\n");
  11134. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11135. if (sizeof(CK_OFF_T) == 8) {
  11136. printf(" Large files and large integers (64 bits)\n");
  11137. if (++lines > cmd_rows - 3) {
  11138. if (!askmore()) return(1); else lines = 0;
  11139. }
  11140. }
  11141. #ifdef NETCONN
  11142. printf(" Network support (type SHOW NET for further info)\n");
  11143. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11144. #ifdef IKS_OPTION
  11145. printf(" Telnet Kermit Option\n");
  11146. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11147. #endif /* IKS_OPTION */
  11148. #ifdef CK_AUTHENTICATION
  11149. printf(" Telnet Authentication Option\n");
  11150. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11151. #ifdef CK_KERBEROS
  11152. #ifdef KRB4
  11153. #ifdef KRB5
  11154. printf(" Kerberos(TM) IV and Kerberos V authentication\n");
  11155. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11156. #else /* KRB5 */
  11157. printf(" Kerberos(TM) IV authentication\n");
  11158. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11159. #endif /* KRB5 */
  11160. #else /* KRB4 */
  11161. #ifdef KRB5
  11162. printf(" Kerberos(TM) V authentication\n");
  11163. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11164. #endif /* KRB5 */
  11165. #endif /* KRB4 */
  11166. #endif /* CK_KERBEROS */
  11167. #ifdef CK_SRP
  11168. printf(" SRP(TM) (Secure Remote Password) authentication\n");
  11169. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11170. #endif /* CK_SRP */
  11171. #ifdef CK_SSL
  11172. printf(" Secure Sockets Layer (SSL)\n");
  11173. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11174. printf(" Transport Layer Security (TLS)\n");
  11175. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11176. #endif /* CK_SSL */
  11177. #ifdef SSHBUILTIN
  11178. printf(" Secure Shell (SSH) [internal]\n");
  11179. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11180. #endif /* SSHBUILTIN */
  11181. #ifdef SSHCMD
  11182. printf(" Secure Shell (SSH) [external]\n");
  11183. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11184. #endif /* SSHCMD */
  11185. #ifdef CK_ENCRYPTION
  11186. printf(" Telnet Encryption Option\n");
  11187. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11188. #ifdef CK_DES
  11189. printf(" Telnet DES Encryption\n");
  11190. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11191. #endif /* CK_DES */
  11192. #ifdef CK_CAST
  11193. printf(" Telnet CAST Encryption\n");
  11194. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11195. #endif /* CK_CAST */
  11196. #ifdef CK_KERBEROS
  11197. #ifdef KRB5
  11198. #ifdef ALLOW_KRB_3DES_ENCRYPT
  11199. printf(" Kerberos 3DES/AES Telnet Encryption\n");
  11200. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11201. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11202. #endif /* KRB5 */
  11203. #endif /* CK_KERBEROS */
  11204. #endif /* CK_ENCRYPTION */
  11205. #endif /* CK_AUTHENTICATION */
  11206. #ifdef CK_FORWARD_X
  11207. printf(" X Windows forwarding\n");
  11208. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11209. #endif /* CK_FORWARD_X */
  11210. #ifdef TN_COMPORT
  11211. printf(" Telnet Remote Com Port Control Option\n");
  11212. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11213. #endif /* TN_COMPORT */
  11214. #ifdef CK_SOCKS
  11215. #ifdef CK_SOCKS5
  11216. printf(" SOCKS 5\n");
  11217. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11218. #else /* CK_SOCKS5 */
  11219. printf(" SOCKS 4\n");
  11220. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11221. #endif /* CK_SOCKS5 */
  11222. #endif /* CK_SOCKS */
  11223. #ifdef NEWFTP
  11224. printf(" Built-in FTP client\n");
  11225. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11226. #endif /* NEWFTP */
  11227. #ifdef CKHTTP
  11228. printf(" Built-in HTTP client\n");
  11229. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11230. #endif /* CKHTTP */
  11231. #endif /* NETCONN */
  11232. #ifdef CK_RTSCTS
  11233. printf(" Hardware flow control\n");
  11234. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11235. #endif /* CK_RTSCTS */
  11236. #ifdef CK_XYZ
  11237. #ifdef XYZ_INTERNAL
  11238. printf(" Built-in XYZMODEM protocols\n");
  11239. #else
  11240. printf(" External XYZMODEM protocol support\n");
  11241. #endif /* XYZ_INTERNAL */
  11242. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11243. #endif /* CK_XYZ */
  11244. #ifndef NOCSETS
  11245. printf(" Latin-1 (West European) character-set translation\n");
  11246. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11247. #ifdef LATIN2
  11248. printf(" Latin-2 (East European) character-set translation\n");
  11249. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11250. #endif /* LATIN2 */
  11251. #ifdef CYRILLIC
  11252. printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
  11253. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11254. #endif /* CYRILLIC */
  11255. #ifdef GREEK
  11256. printf(" Greek character-set translation\n");
  11257. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11258. #endif /* GREEK */
  11259. #ifdef HEBREW
  11260. printf(" Hebrew character-set translation\n");
  11261. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11262. #endif /* HEBREW */
  11263. #ifdef KANJI
  11264. printf(" Japanese character-set translation\n");
  11265. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11266. #endif /* KANJI */
  11267. #ifdef UNICODE
  11268. printf(" Unicode character-set translation\n");
  11269. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11270. #endif /* UNICODE */
  11271. #ifdef CKOUNI
  11272. if (isunicode())
  11273. printf(" Unicode support for ISO-2022 Terminal Emulation\n");
  11274. else
  11275. printf(" Unicode translation for Terminal Character-Sets\n");
  11276. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11277. #endif /* CKOUNI */
  11278. #endif /* NOCSETS */
  11279. #ifdef NETPTY
  11280. printf(" Pseudoterminal control\n");
  11281. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11282. #endif /* NETPTY */
  11283. #ifdef CK_REDIR
  11284. printf(" REDIRECT command\n");
  11285. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11286. #endif /* CK_REDIR */
  11287. #ifdef CK_RESEND
  11288. printf(" RESEND command\n");
  11289. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11290. #endif /* CK_RESEND */
  11291. #ifndef NOXFER
  11292. #ifdef CK_CURSES
  11293. printf(" Fullscreen file transfer display\n");
  11294. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11295. #endif /* CK_CURSES */
  11296. #endif /* NOXFER */
  11297. #ifdef CK_SPEED
  11298. printf(" Control-character unprefixing\n");
  11299. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11300. #endif /* CK_SPEED */
  11301. #ifdef STREAMING
  11302. printf(" Streaming\n");
  11303. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11304. #endif /* STREAMING */
  11305. #ifdef CK_AUTODL
  11306. printf(" Autodownload\n");
  11307. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11308. #endif /* CK_AUTODL */
  11309. #ifdef OS2MOUSE
  11310. printf(" Mouse support\n");
  11311. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11312. #endif /* OS2MOUSE */
  11313. #ifdef CK_REXX
  11314. printf(" REXX script language interface\n");
  11315. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11316. #endif /* CK_REXX */
  11317. #ifdef IKSD
  11318. #ifdef CK_LOGIN
  11319. printf(" Internet Kermit Service with user login support\n");
  11320. #else /* CK_LOGIN */
  11321. printf(" Internet Kermit Service without user login support\n");
  11322. #endif /* CK_LOGIN */
  11323. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11324. #endif /* IKSD */
  11325. printf("\n");
  11326. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11327. printf("Major optional features not included:\n");
  11328. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11329. if (sizeof(CK_OFF_T) <= 4) {
  11330. printf(" No large files or large integers\n");
  11331. if (++lines > cmd_rows - 3) {
  11332. if (!askmore()) return(1); else lines = 0;
  11333. }
  11334. }
  11335. #ifdef NOXFER
  11336. printf(" No file-transfer protocols\n");
  11337. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11338. flag = 1;
  11339. #else
  11340. #ifndef CK_CURSES
  11341. #ifndef MAC
  11342. printf(" No fullscreen file transfer display\n");
  11343. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11344. flag = 1;
  11345. #endif /* MAC */
  11346. #endif /* CK_CURSES */
  11347. #ifdef NOSERVER
  11348. printf(" No server mode\n");
  11349. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11350. flag = 1;
  11351. #endif /* NOSERVER */
  11352. #ifndef CK_SPEED
  11353. printf(" No control-character unprefixing\n");
  11354. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11355. flag = 1;
  11356. #endif /* CK_SPEED */
  11357. #ifndef STREAMING
  11358. printf(" No streaming\n");
  11359. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11360. flag = 1;
  11361. #endif /* STREAMING */
  11362. #ifndef CK_AUTODL
  11363. printf(" No autodownload\n");
  11364. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11365. flag = 1;
  11366. #endif /* CK_AUTODL */
  11367. #ifndef CK_XYZ
  11368. printf(" No built-in XYZMODEM protocols\n");
  11369. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11370. flag = 1;
  11371. #endif /* CK_XYZ */
  11372. #ifdef NOFLOAT
  11373. printf(" No floating-point arithmetic\n");
  11374. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11375. flag = 1;
  11376. printf(" No S-Expressions (LISP interpreter)\n");
  11377. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11378. flag = 1;
  11379. #else
  11380. #ifdef NOSEXP
  11381. printf(" No S-Expressions (LISP interpreter)\n");
  11382. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11383. flag = 1;
  11384. #endif /* NOSEXP */
  11385. #endif /* NOFLOAT */
  11386. #ifdef NOTLOG
  11387. printf(" No transaction log\n");
  11388. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11389. flag = 1;
  11390. #endif /* NOTLOG */
  11391. #endif /* NOXFER */
  11392. #ifdef NODEBUG
  11393. printf(" No debugging\n");
  11394. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11395. flag = 1;
  11396. #endif /* NODEBUG */
  11397. #ifdef NOHELP
  11398. printf(" No built-in help\n");
  11399. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11400. flag = 1;
  11401. #endif /* NOHELP */
  11402. #ifdef NOLOCAL
  11403. printf(" No making connections\n");
  11404. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11405. flag = 1;
  11406. #else
  11407. #ifndef NETCONN
  11408. printf(" No network support\n");
  11409. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11410. flag = 1;
  11411. #else /* NETCONN */
  11412. #ifndef IKS_OPTION
  11413. printf(" No Telnet Kermit Option\n");
  11414. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11415. flag = 1;
  11416. #endif /* IKS_OPTION */
  11417. #endif /* NETCONN */
  11418. #ifdef NOSSH
  11419. printf(" No Secure Shell (SSH)\n");
  11420. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11421. #endif /* NOSSH */
  11422. #ifndef CK_AUTHENTICATION
  11423. printf(" No Kerberos(TM) authentication\n");
  11424. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11425. printf(" No SRP(TM) (Secure Remote Password) protocol\n");
  11426. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11427. printf(" No Secure Sockets Layer (SSL) protocol\n");
  11428. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11429. printf(" No Transport Layer Security (TLS) protocol\n");
  11430. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11431. printf(" No encryption\n");
  11432. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11433. flag = 1;
  11434. #else /* CK_AUTHENTICATION */
  11435. #ifndef CK_KERBEROS
  11436. printf(" No Kerberos(TM) authentication\n");
  11437. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11438. flag = 1;
  11439. #else /* CK_KERBEROS */
  11440. #ifndef KRB4
  11441. printf(" No Kerberos(TM) IV authentication\n");
  11442. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11443. flag = 1;
  11444. #endif /* KRB4 */
  11445. #ifndef KRB5
  11446. printf(" No Kerberos(TM) V authentication\n");
  11447. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11448. flag = 1;
  11449. #endif /* KRB5 */
  11450. #endif /* CK_KERBEROS */
  11451. #ifndef CK_SRP
  11452. printf(" No SRP(TM) (Secure Remote Password) authentication\n");
  11453. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11454. flag = 1;
  11455. #endif /* CK_SRP */
  11456. #ifndef CK_SSL
  11457. printf(" No Secure Sockets Layer (SSL) protocol\n");
  11458. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11459. printf(" No Transport Layer Security (TLS) protocol\n");
  11460. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11461. flag = 1;
  11462. #endif /* CK_SSL */
  11463. #ifndef CK_ENCRYPTION
  11464. printf(" No Telnet Encryption Option\n");
  11465. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11466. flag = 1;
  11467. #else /* CK_ENCRYPTION */
  11468. #ifndef OS2
  11469. #ifndef CK_DES
  11470. printf(" No Telnet DES encryption\n");
  11471. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11472. flag = 1;
  11473. #endif /* CK_DES */
  11474. #ifndef CK_CAST
  11475. printf(" No Telnet CAST encryption\n");
  11476. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11477. flag = 1;
  11478. #endif /* CK_CAST */
  11479. #ifdef COMMENT
  11480. #ifdef CK_KERBEROS
  11481. #ifdef KRB5
  11482. #ifndef ALLOW_KRB_3DES_ENCRYPT
  11483. printf(" No Kerberos 3DES/AES Telnet Encryption\n");
  11484. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11485. #endif /* ALLOW_KRB_3DES_ENCRYPT */
  11486. #endif /* KRB5 */
  11487. #endif /* CK_KERBEROS */
  11488. #endif /* COMMENT */
  11489. #endif /* OS2 */
  11490. #endif /* CK_ENCRYPTION */
  11491. #endif /* CK_AUTHENTICATION */
  11492. #ifndef CK_FORWARD_X
  11493. printf(" No X Windows forwarding\n");
  11494. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11495. #endif /* CK_FORWARD_X */
  11496. #ifndef TN_COMPORT
  11497. printf(" No Telnet Remote Com Port Control Option\n");
  11498. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11499. #endif /* TN_COMPORT */
  11500. #ifndef CK_SOCKS
  11501. printf(" No SOCKS\n");
  11502. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11503. #endif /* CK_SOCKS */
  11504. #ifndef NEWFTP
  11505. printf(" No built-in FTP client\n");
  11506. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11507. #endif /* NEWFTP */
  11508. #ifdef NOHTTP
  11509. printf(" No built-in HTTP client\n");
  11510. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11511. #endif /* NOHTTP */
  11512. #ifdef NODIAL
  11513. printf(" No DIAL command\n");
  11514. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11515. flag = 1;
  11516. #else
  11517. #ifdef MINIDIAL
  11518. printf(" Support for most modem types excluded\n");
  11519. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11520. flag = 1;
  11521. #endif /* MINIDIAL */
  11522. #endif /* NODIAL */
  11523. #endif /* NOLOCAL */
  11524. #ifndef CK_RTSCTS
  11525. #ifndef MAC
  11526. printf(" No hardware flow control\n");
  11527. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11528. flag = 1;
  11529. #endif /* MAC */
  11530. #endif /* CK_RTSCTS */
  11531. #ifdef NOXMIT
  11532. printf(" No TRANSMIT command\n");
  11533. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11534. flag = 1;
  11535. #endif /* NOXMIT */
  11536. #ifdef NOSCRIPT
  11537. printf(" No SCRIPT command\n");
  11538. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11539. flag = 1;
  11540. #endif /* NOSCRIPT */
  11541. #ifdef NOSPL
  11542. printf(" No script programming features\n");
  11543. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11544. flag = 1;
  11545. #endif /* NOSPL */
  11546. #ifdef NOCSETS
  11547. printf(" No character-set translation\n");
  11548. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11549. flag = 1;
  11550. #else
  11551. #ifndef LATIN2
  11552. printf(" No Latin-2 character-set translation\n");
  11553. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11554. flag = 1;
  11555. #endif /* LATIN2 */
  11556. #ifdef NOGREEK
  11557. printf(" No Greek character-set translation\n");
  11558. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11559. flag = 1;
  11560. #endif /* NOGREEK */
  11561. #ifdef NOHEBREW
  11562. printf(" No Hebrew character-set translation\n");
  11563. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11564. flag = 1;
  11565. #endif /* NOHEBREW */
  11566. #ifdef NOUNICODE
  11567. printf(" No Unicode character-set translation\n");
  11568. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11569. flag = 1;
  11570. #endif /* NOUNICODE */
  11571. #ifdef NOCYRIL
  11572. printf(" No Cyrillic character-set translation\n");
  11573. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11574. flag = 1;
  11575. #endif /* NOCYRIL */
  11576. #ifndef KANJI
  11577. printf(" No Kanji character-set translation\n");
  11578. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11579. flag = 1;
  11580. #endif /* KANJI */
  11581. #endif /* NOCSETS */
  11582. #ifdef NOCMDL
  11583. printf(" No command-line arguments\n");
  11584. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11585. flag = 1;
  11586. #endif /* NOCMDL */
  11587. #ifdef NOPUSH
  11588. printf(" No escape to system\n");
  11589. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11590. flag = 1;
  11591. #endif /* NOPUSH */
  11592. #ifdef NOJC
  11593. #ifdef UNIX
  11594. printf(" No UNIX job control\n");
  11595. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11596. flag = 1;
  11597. #endif /* UNIX */
  11598. #endif /* NOJC */
  11599. #ifdef NOSETKEY
  11600. printf(" No SET KEY command\n");
  11601. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11602. flag = 1;
  11603. #endif /* NOSETKEY */
  11604. #ifndef CK_REDIR
  11605. printf(" No REDIRECT or PIPE command\n");
  11606. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11607. flag = 1;
  11608. #endif /* CK_REDIR */
  11609. #ifdef UNIX
  11610. #ifndef NETPTY
  11611. printf(" No pseudoterminal control\n");
  11612. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11613. flag = 1;
  11614. #endif /* NETPTY */
  11615. #endif /* UNIX */
  11616. #ifndef CK_RESEND
  11617. printf(" No RESEND command\n");
  11618. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11619. flag = 1;
  11620. #endif /* CK_RESEND */
  11621. #ifdef OS2
  11622. #ifdef __32BIT__
  11623. #ifndef OS2MOUSE
  11624. printf(" No Mouse support\n");
  11625. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11626. flag = 1;
  11627. #endif /* __32BIT__ */
  11628. #endif /* OS2 */
  11629. #endif /* OS2MOUSE */
  11630. #ifdef OS2
  11631. #ifndef NT
  11632. #ifndef CK_REXX
  11633. printf(" No REXX script language interface\n");
  11634. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11635. flag = 1;
  11636. #endif /* CK_REXX */
  11637. #endif /* NT */
  11638. #endif /* OS2 */
  11639. #ifndef IKSD
  11640. printf(" No Internet Kermit Service\n");
  11641. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11642. flag = 1;
  11643. #endif /* IKSD */
  11644. if (flag == 0) {
  11645. printf(" None\n");
  11646. if (++lines > cmd_rows - 3)
  11647. { if (!askmore()) return(1); else lines = 0; }
  11648. }
  11649. printf("\n");
  11650. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11651. #ifdef CK_UTSNAME
  11652. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11653. printf("Host info:\n");
  11654. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11655. printf(" Machine: %s\n",unm_mch[0] ? unm_mch : "(unknown)");
  11656. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11657. printf(" Model: %s\n",unm_mod[0] ? unm_mod : "(unknown)");
  11658. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11659. printf(" OS: %s\n",unm_nam[0] ? unm_nam : "(unknown)");
  11660. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11661. printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
  11662. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11663. printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
  11664. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11665. printf("\n");
  11666. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11667. #endif /* CK_UTSNAME */
  11668. /*
  11669. Print compile-time (-D) options, as well as C preprocessor
  11670. predefined symbols that might affect us...
  11671. */
  11672. #ifdef KTARGET
  11673. {
  11674. char * s; /* Makefile target */
  11675. s = KTARGET;
  11676. if (!s) s = "";
  11677. if (!*s) s = "(unknown)";
  11678. printf("\n");
  11679. if (++lines > cmd_rows - 3) {
  11680. if (!askmore()) return(1); else lines = 0;
  11681. }
  11682. printf("Target: %s\n", s);
  11683. if (++lines > cmd_rows - 3) {
  11684. if (!askmore()) return(1); else lines = 0;
  11685. }
  11686. }
  11687. #endif /* KTARGET */
  11688. #ifdef __VERSION__
  11689. #ifdef __GNUC__
  11690. printf("GCC version: %s\n", __VERSION__);
  11691. #else
  11692. printf("Compiler version: %s\n", __VERSION__);
  11693. #endif /* __GNUC__ */
  11694. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11695. #endif /* __VERSION__ */
  11696. #ifdef __DATE__ /* GNU and other ANSI */
  11697. #ifdef __TIME__
  11698. printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
  11699. #else
  11700. printf("Compiled %s, options:\n", __DATE__);
  11701. #endif /* __TIME__ */
  11702. #else /* !__DATE__ */
  11703. printf("Compiler options:\n");
  11704. #endif /* __DATE__ */
  11705. if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
  11706. for (i = 0; i < noptlist; i++) /* Print sorted option list */
  11707. if (!prtopt(&lines,optlist[i]))
  11708. return(0);
  11709. if (!prtopt(&lines,"")) return(0); /* Start a new section */
  11710. /* Sizes of data types */
  11711. ckmakmsg(line,
  11712. LINBUFSIZ,
  11713. "byte order: ",
  11714. byteorder ? "little" : "big",
  11715. " endian",
  11716. NULL
  11717. );
  11718. {
  11719. /* Whether to use %d or %ld with sizeof is a portability issue, so... */
  11720. int size = 0;
  11721. if (!prtopt(&lines,line)) return(0);
  11722. if (!prtopt(&lines,"")) return(0); /* Start a new section */
  11723. size = (int)sizeof(int);
  11724. sprintf(line,"sizeofs: int=%d",size); /* SAFE */
  11725. if (!prtopt(&lines,line)) return(0);
  11726. size = (int)sizeof(long);
  11727. sprintf(line,"long=%d",size); /* SAFE */
  11728. if (!prtopt(&lines,line)) return(0);
  11729. #ifndef OS2
  11730. /* Windows doesn't have off_t */
  11731. size = (int)sizeof(off_t);
  11732. sprintf(line,"off_t=%d",size); /* SAFE */
  11733. if (!prtopt(&lines,line)) return(0);
  11734. #endif /* OS2 */
  11735. size = (int)sizeof(CK_OFF_T);
  11736. sprintf(line,"CK_OFF_T=%d",size); /* SAFE */
  11737. if (!prtopt(&lines,line)) return(0);
  11738. #ifdef BIGBUFOK
  11739. size = (int)sizeof(size_t);
  11740. sprintf(line,"size_t=%d",size); /* SAFE */
  11741. if (!prtopt(&lines,line)) return(0);
  11742. #endif /* BIGBUFOK */
  11743. size = (int)sizeof(short);
  11744. sprintf(line,"short=%d",size); /* SAFE */
  11745. if (!prtopt(&lines,line)) return(0);
  11746. size = (int)sizeof(char);
  11747. sprintf(line,"char=%d",size); /* SAFE */
  11748. if (!prtopt(&lines,line)) return(0);
  11749. size = (int)sizeof(char *);
  11750. sprintf(line,"char*=%d",size); /* SAFE */
  11751. if (!prtopt(&lines,line)) return(0);
  11752. size = (int)sizeof(float);
  11753. sprintf(line,"float=%d",size); /* SAFE */
  11754. if (!prtopt(&lines,line)) return(0);
  11755. size = (int)sizeof(double);
  11756. sprintf(line,"double=%d",size); /* SAFE */
  11757. if (!prtopt(&lines,line)) return(0);
  11758. }
  11759. #ifdef FNFLOAT
  11760. if (!prtopt(&lines,"")) return(0); /* Start a new section */
  11761. if (!prtopt(&lines,"floating-point:")) return(0);
  11762. sprintf(line,"precision=%d",fp_digits); /* SAFE */
  11763. if (!prtopt(&lines,line)) return(0);
  11764. sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
  11765. if (!prtopt(&lines,line)) return(0);
  11766. #endif /* FNFLOAT */
  11767. prtopt(&lines,"");
  11768. return(0);
  11769. }
  11770. #endif /* NOSHOW */
  11771. #endif /* NOICP */