ckuusr.c 355 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587
  1. #ifdef SSHTEST
  2. #define SSHBUILTIN
  3. #endif /* SSHTEST */
  4. #include "ckcsym.h"
  5. char *userv = "User Interface 9.0.314, 25 Apr 2017";
  6. /* C K U U S R -- "User Interface" for C-Kermit (Part 1) */
  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. /*
  19. Originally the entire user interface was in one module, ckuusr.c. Over
  20. the years it has been split into many modules: ckuus2.c, ckuus3.c, ...,
  21. ckuus7.c. ckuus2.c contains the HELP command parser and help-text strings;
  22. ckuusy.c contains the UNIX-style command-line interface; ckuusx.c contains
  23. routines needed by both the command-line interface and the interactive
  24. command parser.
  25. */
  26. /*
  27. The ckuus*.c modules depend on the existence of C library features like
  28. fopen, fgets, feof, (f)printf, argv/argc, etc. Other functions that are
  29. likely to vary among different platforms -- like setting terminal modes or
  30. interrupts -- are invoked via calls to functions that are defined in the
  31. system- dependent modules, ck?[ft]io.c. The command line parser processes
  32. any arguments found on the command line, as passed to main() via argv/argc.
  33. The interactive parser uses the facilities of the cmd package (developed for
  34. this program, but usable by any program). Any command parser may be
  35. substituted for this one. The only requirements for the Kermit command
  36. parser are these:
  37. . Set parameters via global variables like duplex, speed, ttname, etc. See
  38. ckcmai.c for the declarations and descriptions of these variables.
  39. . If a command can be executed without the use of Kermit protocol, then
  40. execute the command directly and set the variable sstate to 0. Examples
  41. include 'set' commands, local directory listings, the 'connect' command.
  42. . If a command requires the Kermit protocol, set the following variables:
  43. sstate string data
  44. 'x' (enter server mode) (none)
  45. 'r' (send a 'get' command) cmarg, cmarg2
  46. 'v' (enter receive mode) cmarg2
  47. 'g' (send a generic command) cmarg
  48. 's' (send files) nfils, cmarg & cmarg2 OR cmlist
  49. 'c' (send a remote host command) cmarg
  50. cmlist is an array of pointers to strings.
  51. cmarg, cmarg2 are pointers to strings.
  52. nfils is an integer.
  53. cmarg can be a filename string (possibly wild), or
  54. a pointer to a prefabricated generic command string, or
  55. a pointer to a host command string.
  56. cmarg2 is an "as-name" - the name to send file(s) under, or
  57. the name under which to store incoming file(s); must not be wild.
  58. A null or empty value means to use the file's own name.
  59. cmlist is a list of filenames, such as passed via argv.
  60. nfils is an integer, interpreted as follows:
  61. -1: filespec (possibly wild) in cmarg, must be expanded internally.
  62. 0: send from stdin (standard input).
  63. >0: number of files to send, from cmlist.
  64. The screen() function is used to update the screen during file transfer.
  65. The tlog() function writes to a transaction log.
  66. The debug() function writes to a debugging log.
  67. The intmsg() and chkint() functions provide the user i/o for interrupting
  68. file transfers.
  69. */
  70. /* Includes */
  71. #ifdef MULTINET
  72. #define MULTINET_OLD_STYLE /* Leave select prototype undefined */
  73. #endif /* MULTINET */
  74. #include "ckcdeb.h"
  75. #include "ckcasc.h"
  76. #include "ckcker.h"
  77. #include "ckcnet.h" /* Network symbols */
  78. #include "ckuusr.h"
  79. #include "ckcxla.h"
  80. int g_fncact = -1; /* Needed for NOICP builds */
  81. int noinit = 0; /* Flag for skipping init file */
  82. int nscanfile = SCANFILEBUF;
  83. int rcdactive = 0; /* RCD active */
  84. int keepallchars = 0; /* See cmfld() */
  85. int locus = 1; /* Current LOCUS is LOCAL */
  86. #ifdef OS2
  87. int autolocus = 2; /* Automatic LOCUS switching: ASK */
  88. #else /* OS2 */
  89. int autolocus = 1; /* Automatic LOCUS switching enabled */
  90. #endif /* OS2 */
  91. #ifndef NOICP
  92. #ifdef CKLEARN
  93. #ifdef VMS
  94. #include <time.h> /* For CKLEARN */
  95. #endif /* VMS */
  96. #endif /* CKLEARN */
  97. #ifdef OS2
  98. #ifndef NT
  99. #define INCL_NOPM
  100. #define INCL_VIO /* Needed for ckocon.h */
  101. #include <os2.h>
  102. #undef COMMENT
  103. #else
  104. #define APIRET ULONG
  105. #include <windows.h>
  106. #include <tapi.h>
  107. #include "cknwin.h"
  108. #include "ckntap.h" /* CK_TAPI definition */
  109. #endif /* NT */
  110. #include "ckowin.h"
  111. #include "ckocon.h"
  112. extern int tcp_avail;
  113. extern bool viewonly;
  114. extern int k95stdout;
  115. extern int tt_scroll;
  116. #ifndef NOTERM
  117. extern tt_status[VNUM];
  118. #endif /* NOTERM */
  119. #include "ckossh.h"
  120. #ifdef KUI
  121. #include "ikui.h"
  122. #endif /* KUI */
  123. #endif /* OS2 */
  124. int optlines = 0;
  125. int didsetlin = 0;
  126. #ifdef NEWFTP
  127. extern int ftpget, ftpisopen(), doftpres();
  128. _PROTOTYP(int doftptyp,(int));
  129. _PROTOTYP(VOID doftpglobaltype,(int));
  130. #endif /* NEWFTP */
  131. #ifdef VMS
  132. extern int batch;
  133. #endif /* VMS */
  134. #ifdef datageneral
  135. #include <packets:common.h>
  136. #define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
  137. #endif /* datageneral */
  138. extern int xcmdsrc, hints, cmflgs, whyclosed;
  139. int isinternal = 0; /* Flag for internally-defined macro */
  140. char * hlptok = NULL;
  141. #ifdef CK_TTGWSIZ /* Whether to use more-prompting */
  142. int xaskmore = 1; /* Momentary setting */
  143. int saveask = 1; /* Permanent setting */
  144. #else
  145. int xaskmore = 0;
  146. int saveask = 0;
  147. #endif /* CK_TTGWSIZ */
  148. #ifndef NOCSETS
  149. extern int nfilc;
  150. extern struct keytab fcstab[];
  151. extern int fcharset;
  152. #endif /* NOCSETS */
  153. char * g_pswd = NULL;
  154. int g_pcpt = -1;
  155. int g_pflg = -1;
  156. extern int cmd_rows, cmd_cols;
  157. #ifdef CKROOT
  158. extern int ckrooterr;
  159. #endif /* CKROOT */
  160. extern int inserver, filepeek;
  161. #ifdef CKLEARN
  162. FILE * learnfp = NULL;
  163. char * learnfile = NULL;
  164. int learning = 0;
  165. #endif /* CKLEARN */
  166. #ifndef NOXFER
  167. extern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size,
  168. sndsrc, server, displa, fncnv, fnspath, fnrpath, xfermode, urpsiz,
  169. spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact, reliable,
  170. setreliable;
  171. #ifdef IKSDCONF
  172. extern int iksdcf;
  173. #endif /* IKSDCONF */
  174. #ifdef CK_LOGIN
  175. extern int isguest;
  176. #endif /* CK_LOGIN */
  177. extern CK_OFF_T sendstart;
  178. extern char *cmarg, *cmarg2, **cmlist, *dftty;
  179. extern struct keytab fntab[]; extern int nfntab;
  180. extern struct ck_p ptab[NPROTOS];
  181. int sndcmd = 0; /* Last command was a SEND-class command. */
  182. int g_xfermode = -1;
  183. int g_proto = -1;
  184. int g_urpsiz = -1;
  185. int g_spsizf = -1;
  186. int g_spsiz = -1;
  187. int g_spsizr = -1;
  188. int g_spmax = -1;
  189. int g_wslotr = -1;
  190. int g_prefixing = -1;
  191. int g_fncnv = -1;
  192. int g_fnspath = -1;
  193. int g_fnrpath = -1;
  194. int g_fnact = -1;
  195. int g_displa = -1;
  196. int g_spath = -1;
  197. int g_rpath = -1;
  198. char * g_sfilter = NULL;
  199. char * g_rfilter = NULL;
  200. extern int patterns;
  201. #ifdef PATTERNS
  202. extern char *txtpatterns[], *binpatterns[];
  203. int g_patterns = -1;
  204. #endif /* PATTERNS */
  205. int g_skipbup = -1;
  206. #ifdef PIPESEND
  207. extern int usepipes, pipesend;
  208. extern char * sndfilter;
  209. #endif /* PIPESEND */
  210. #ifndef NOSPL
  211. extern int sndxlo, sndxhi, sndxin;
  212. #endif /* NOSPL */
  213. extern char fspec[]; /* Most recent filespec */
  214. extern int fspeclen; /* Length of fspec[] buffer */
  215. #ifndef NOFRILLS
  216. extern int rmailf; /* MAIL command items */
  217. extern char optbuf[];
  218. #endif /* NOFRILLS */
  219. extern int
  220. en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri,
  221. en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit,
  222. en_mkd, en_rmd, en_asg;
  223. #ifndef NOMSEND /* Multiple SEND */
  224. extern char *msfiles[];
  225. int filesinlist = 0; /* And ADD ... */
  226. extern struct filelist * filehead;
  227. extern struct filelist * filetail;
  228. extern struct filelist * filenext;
  229. extern int addlist;
  230. #endif /* NOMSEND */
  231. static struct keytab addtab[] = {
  232. #ifdef PATTERNS
  233. { "binary-patterns", ADD_BIN, 0 },
  234. #endif /* PATTERNS */
  235. #ifndef NOMSEND
  236. { "send-list", ADD_SND, 0 },
  237. #endif /* NOMSEND */
  238. #ifdef PATTERNS
  239. { "text-patterns", ADD_TXT, 0 },
  240. #endif /* PATTERNS */
  241. { "", 0, 0 }
  242. };
  243. static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;
  244. #ifndef NOCSETS
  245. struct keytab assoctab[] = {
  246. { "file-character-set", ASSOC_FC, 0 },
  247. { "transfer-character-set", ASSOC_TC, 0 },
  248. { "xfer-character-set", ASSOC_TC, CM_INV }
  249. };
  250. static int nassoc = sizeof(assoctab)/sizeof(struct keytab);
  251. extern int afcset[MAXFCSETS+1]; /* Character-set associations */
  252. extern int axcset[MAXTCSETS+1];
  253. #endif /* NOCSETS */
  254. #ifndef ADDCMD
  255. #ifndef NOMSEND
  256. #define ADDCMD
  257. #endif /* NOMSEND */
  258. #ifndef ADDCMD
  259. #ifdef PATTERNS
  260. #define ADDCMD
  261. #endif /* PATTERNS */
  262. #endif /* ADDCMD */
  263. #endif /* ADDCMD */
  264. #endif /* NOXFER */
  265. /* External Kermit Variables, see ckmain.c for description. */
  266. extern xx_strp xxstring;
  267. extern long xvernum;
  268. extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel,
  269. pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;
  270. #ifdef TNCODE
  271. extern int debses;
  272. extern char tn_msg[];
  273. #endif /* TNCODE */
  274. int sleepcan = 1;
  275. int g_binary = -1;
  276. int g_recursive = -1;
  277. int g_matchdot = -1;
  278. extern int nolinks;
  279. extern long vernum;
  280. extern char *versio, *copyright[];
  281. extern char *ckxsys;
  282. #ifndef NOHELP
  283. extern char *introtxt[];
  284. extern char *newstxt[];
  285. #endif /* NOHELP */
  286. #ifndef OS2
  287. #ifndef UNIX
  288. extern char *PWDCMD;
  289. #endif /* UNIX */
  290. extern char *WHOCMD;
  291. #endif /* OS2 */
  292. extern char ttname[];
  293. extern CHAR sstate;
  294. extern int network; /* Have active network connection */
  295. extern int nettype; /* Type of network */
  296. extern int ttnproto; /* NET_TCPB protocol */
  297. #ifndef NODIAL
  298. extern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */
  299. #endif /* NODIAL */
  300. #ifdef CK_APC
  301. extern int apcactive, apcstatus;
  302. #endif /* CK_APC */
  303. #ifndef NOPUSH
  304. #ifndef NOFRILLS
  305. extern char editor[];
  306. extern char editopts[];
  307. extern char editfile[];
  308. #endif /* NOFRILLS */
  309. #endif /* NOPUSH */
  310. #ifdef BROWSER
  311. extern char browser[]; /* Web browser application */
  312. extern char browsopts[]; /* Web browser options */
  313. extern char browsurl[]; /* Most recent URL */
  314. #endif /* BROWSER */
  315. #ifndef NOFTP
  316. char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */
  317. char ftpopts[128] = { NUL, NUL }; /* ftp command-line options */
  318. #endif /* NOFTP */
  319. extern struct keytab onoff[]; /* On/Off keyword table */
  320. #ifdef CK_TMPDIR
  321. int f_tmpdir = 0; /* Directory changed temporarily */
  322. char savdir[TMPDIRLEN]; /* For saving current directory */
  323. #endif /* CK_TMPDIR */
  324. int activecmd = -1; /* Keyword index of active command */
  325. int doconx = -1; /* CONNECT-class command active */
  326. int ooflag = 0; /* User-settable on/off flag */
  327. int rcflag = 0; /* Pointer to home directory string */
  328. int repars, /* Reparse needed */
  329. techo = 0; /* Take echo */
  330. int secho = 1; /* SCRIPT echo */
  331. int xitwarn = /* Warn about open connection on exit */
  332. #ifdef NOWARN
  333. 0
  334. #else
  335. 1
  336. #endif /* NOWARN */
  337. ;
  338. struct keytab onoffsw[] = {
  339. { "/off", 0, 0 },
  340. { "/on", 1, 0 }
  341. };
  342. #ifdef CKEXEC
  343. struct keytab redirsw[] = {
  344. { "/redirect", 1, 0 }
  345. };
  346. #endif /* CKEXEC */
  347. #ifndef NOXMIT
  348. /* Variables for TRANSMIT command */
  349. int xmitx = 1; /* Whether to echo during TRANSMIT */
  350. int xmitf = 0; /* Character to fill empty lines */
  351. int xmitl = 0; /* 0 = Don't send linefeed too */
  352. int xmitp = LF; /* Host line prompt */
  353. int xmits = 0; /* Use shift-in/shift-out, 0 = no */
  354. int xmitw = 0; /* Milliseconds to pause during TRANSMIT */
  355. int xmitt = 1; /* Seconds to wait for each char to echo */
  356. int xmita = 1; /* Action upon timeout */
  357. #define XMI_BIN 1
  358. #define XMI_TXT 2
  359. #define XMI_CMD 3
  360. #define XMI_TRA 4
  361. #define XMI_VRB 5
  362. #define XMI_QUI 6
  363. #define XMI_NOW 7
  364. #define XMI_NOE 8
  365. static struct keytab xmitsw[] = { /* TRANSMIT command options */
  366. { "/binary", XMI_BIN, 0 },
  367. #ifdef PIPESEND
  368. { "/command", XMI_CMD, CM_INV|CM_PSH },
  369. #endif /* PIPESEND */
  370. { "/noecho", XMI_NOE, 0 },
  371. { "/nowait", XMI_NOW, 0 },
  372. #ifdef PIPESEND
  373. { "/pipe", XMI_CMD, 0 },
  374. #endif /* PIPESEND */
  375. #ifdef COMMENT
  376. { "/quiet", XMI_QUI, 0 },
  377. #endif /* COMMENT */
  378. { "/text", XMI_TXT, 0 },
  379. { "/transparent", XMI_TRA, 0 },
  380. #ifdef COMMENT
  381. { "/verbose", XMI_VRB, 0 },
  382. #endif /* COMMENT */
  383. { "", 0, 0 }
  384. };
  385. #define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1
  386. static int nxmitsw = NXMITSW;
  387. #endif /* NOXMIT */
  388. /* Declarations from ck?fio.c module */
  389. extern char *SPACMD, *SPACM2; /* SPACE commands */
  390. /* Command-oriented items */
  391. #ifdef DCMDBUF
  392. extern char *cmdbuf; /* Command buffers */
  393. extern char *atmbuf;
  394. extern char *line; /* Character buffer for anything */
  395. extern char *tmpbuf; /* Short temporary string buffer */
  396. extern int *ifcmd;
  397. extern int *intime;
  398. extern int *inpcas;
  399. #else
  400. extern char cmdbuf[]; /* Command buffers */
  401. extern char atmbuf[];
  402. extern char line[]; /* Character buffer for anything */
  403. extern char tmpbuf[]; /* Temporary buffer */
  404. extern int ifcmd[];
  405. extern int intime[];
  406. extern int inpcas[];
  407. #endif /* DCMDBUF */
  408. #ifndef NOSPL
  409. extern char * prstring[];
  410. #endif /* NOSPL */
  411. char *lp; /* Pointer to line buffer */
  412. #ifndef NOSPL
  413. int vareval = 1; /* Evaluation method */
  414. int unkmacro = 0; /* Flag for in ON_UNKNOWN_COMMAND */
  415. int oldeval = 0;
  416. char evalbuf[33]; /* EVALUATE result */
  417. extern char * inpbuf; /* Buffer for INPUT and REINPUT */
  418. char *inpbp; /* And pointer to same */
  419. int m_found; /* MINPUT result */
  420. int i_active = 0; /* INPUT command is active */
  421. char *ms[MINPMAX]; /* Pointers to MINPUT strings */
  422. static int mpinited = 0; /* Flag they have been initialized */
  423. static int mp[MINPMAX]; /* and MINPUT flags */
  424. extern int fndiags, fnerror, fnsuccess; /* Function diagnostics */
  425. #ifndef NOSEXP
  426. char * lastsexp = NULL; /* S-Expressions */
  427. char * sexpval = NULL;
  428. int sexpecho = SET_AUTO;
  429. #endif /* NOSEXP */
  430. #endif /* NOSPL */
  431. char psave[PROMPTL] = { NUL }; /* For saving & restoring prompt */
  432. extern int success; /* Command success/failure flag */
  433. extern int cmdlvl; /* Current position in command stack */
  434. #ifndef NOSPL
  435. int /* SET INPUT parameters. */
  436. /* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */
  437. inbufsize = 0, /* INPUT buffer size */
  438. indef = 1, /* default timeout, seconds */
  439. inecho = 1, /* 1 = echo on */
  440. inautodl = 0, /* INPUT autodownload */
  441. inintr = 1, /* INPUT interrupion allowed */
  442. insilence = 0; /* 0 = no silence constraint */
  443. #ifdef CKFLOAT
  444. CKFLOAT inscale = 1.0; /* Timeout scale factor */
  445. #endif /* CKFLOAT */
  446. #ifdef OS2
  447. int interm = 1; /* Terminal emulator displays input */
  448. #endif /* OS2 */
  449. int maclvl = -1; /* Macro nesting level */
  450. int mecho = 0; /* Macro echo, 0 = don't */
  451. char varnam[6]; /* For variable names */
  452. extern int macargc[]; /* ARGC from macro invocation */
  453. extern char *m_arg[MACLEVEL][NARGS]; /* Stack of macro arguments */
  454. extern char *mrval[];
  455. extern char **a_ptr[]; /* Array pointers */
  456. extern int a_dim[]; /* Array dimensions */
  457. extern int a_link[];
  458. #ifdef DCMDBUF
  459. extern struct cmdptr *cmdstk; /* The command stack itself */
  460. #else
  461. extern struct cmdptr cmdstk[]; /* The command stack itself */
  462. #endif /* DCMDBUF */
  463. long ck_alarm = 0; /* SET ALARM value */
  464. char alrm_date[24] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  465. char alrm_time[24] = { ' ',' ',' ',' ',' ',' ',' ' };
  466. struct keytab inputsw[] = {
  467. { "/clear", INPSW_CLR, 0 },
  468. { "/count", INPSW_COU, CM_ARG },
  469. { "/nomatch", INPSW_NOM, 0 },
  470. { "/nowrap", INPSW_NOW, 0 }
  471. };
  472. static int ninputsw = sizeof(inputsw)/sizeof(struct keytab);
  473. /* The following should be reconciled with the above */
  474. #ifdef COMMENT /* INPUT switches not used yet... */
  475. static struct keytab inswtab[] = {
  476. #ifdef COMMENT
  477. { "/assign", IN_ASG, CM_ARG },
  478. #endif /* COMMENT */
  479. { "/autodownload", IN_ADL, CM_ARG },
  480. { "/case", IN_CAS, CM_ARG },
  481. { "/echo", IN_ECH, CM_ARG },
  482. { "/interrupts", IN_NOI, CM_ARG },
  483. { "/silence", IN_SIL, CM_ARG },
  484. #ifdef COMMENT
  485. { "/pattern", IN_PAT, CM_ARG },
  486. #endif /* COMMENT */
  487. { "", 0, 0 }
  488. };
  489. static int ninswtab = (sizeof(inswtab) / sizeof(struct keytab)) - 1;
  490. #endif /* COMMENT */
  491. #endif /* NOSPL */
  492. static int x, y, z = 0; /* Local workers */
  493. static char *s;
  494. #ifdef CK_MINPUT
  495. static char c1chars[] = { /* C1 control chars escept NUL */
  496. 001,002,003,004,005,006,007,010,011,012,013,014,015,016,017,020,
  497. 021,022,023,024,025,026,027,030,031,032,033,034,035,036,037
  498. };
  499. #endif /* CK_MINPUT */
  500. #define xsystem(s) zsyscmd(s)
  501. /* Top-Level Interactive Command Keyword Table */
  502. /* Keywords must be in lowercase and in alphabetical order. */
  503. struct keytab cmdtab[] = {
  504. #ifndef NOPUSH
  505. { "!", XXSHE, CM_INV|CM_PSH }, /* Shell escape */
  506. #else
  507. { "!", XXNOTAV, CM_INV|CM_PSH },
  508. #endif /* NOPUSH */
  509. { "#", XXCOM, CM_INV }, /* Comment */
  510. #ifndef NOSPL
  511. { "(", XXSEXP,CM_INV }, /* S-Expression */
  512. { ".", XXDEF, CM_INV }, /* Assignment */
  513. { ":", XXLBL, CM_INV }, /* Label */
  514. #endif /* NOSPL */
  515. #ifdef CK_REDIR
  516. #ifndef NOPUSH
  517. { "<", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  518. #else
  519. { "<", XXNOTAV, CM_INV|CM_PSH }, /* REDIRECT */
  520. #endif /* NOPUSH */
  521. #endif /* CK_REDIR */
  522. #ifndef NOPUSH
  523. { "@", XXSHE, CM_INV|CM_PSH }, /* DCL escape */
  524. #else
  525. { "@", XXNOTAV, CM_INV|CM_PSH }, /* DCL escape */
  526. #endif /* NOPUSH */
  527. #ifdef CK_RECALL
  528. { "^", XXREDO,CM_INV|CM_NOR }, /* Synonym for REDO */
  529. #endif /* CK_RECALL */
  530. #ifndef NOSPL
  531. { "_asg", XXASX, CM_INV }, /* Used internally by FOR, etc */
  532. { "_assign", XXASX, CM_INV }, /* Used internally by FOR, etc */
  533. { "_decrement", XX_DECR, CM_INV },
  534. { "_define", XXDFX, CM_INV }, /* Used internally by FOR, etc */
  535. { "_evaluate", XX_EVAL, CM_INV },
  536. { "_forward", XXXFWD, CM_INV }, /* Used internally by SWITCH */
  537. { "_getargs", XXGTA, CM_INV }, /* Used internally by FOR, etc */
  538. { "_increment", XX_INCR, CM_INV },
  539. { "_putargs", XXPTA, CM_INV }, /* Used internally by FOR, etc */
  540. { "_undefine", XXUNDFX, CM_INV },
  541. #endif /* NOSPL */
  542. { "about", XXVER, CM_INV }, /* Synonym for VERSION */
  543. #ifndef NOSPL
  544. #ifdef NEWFTP
  545. { "account", XXACCT, CM_INV }, /* (FTP) Account */
  546. #endif /* NEWFTP */
  547. #ifdef ADDCMD
  548. { "add", XXADD, 0 }, /* ADD */
  549. #endif /* ADDCMD */
  550. #ifndef NODIAL
  551. { "answer", XXANSW, CM_LOC }, /* ANSWER the phone */
  552. #else
  553. { "answer", XXNOTAV, CM_INV|CM_LOC }, /* ANSWER the phone */
  554. #endif /* NODIAL */
  555. { "apc", XXAPC, 0 }, /* Application Program Command */
  556. #ifndef NOSPL
  557. { "array", XXARRAY, 0 }, /* Array operations */
  558. #endif /* NOSPL */
  559. { "ascii", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */
  560. { "asg", XXASS, CM_INV }, /* Invisible synonym for ASSIGN */
  561. { "ask", XXASK, 0 }, /* ASK for text, assign to variable */
  562. { "askq", XXASKQ,0 }, /* ASK quietly (no echo) */
  563. #ifndef NOSPL
  564. { "ass", XXASS, CM_INV|CM_ABR }, /* ASSIGN */
  565. { "assert", XXASSER, CM_INV }, /* ASSERT */
  566. { "assign", XXASS, 0 }, /* ASSIGN */
  567. #endif /* NOSPL */
  568. #ifndef NOXFER
  569. #ifndef NOCSETS
  570. { "associate", XXASSOC, 0 }, /* ASSOCIATE */
  571. #else
  572. { "associate", XXNOTAV, CM_INV }, /* ASSOCIATE */
  573. #endif /* NOCSETS */
  574. #endif /* NOXFER */
  575. #ifdef CK_KERBEROS
  576. #ifdef CK_AUTHENTICATION
  577. { "authenticate",XXAUTH, 0 }, /* Authentication */
  578. #else
  579. { "authenticate",XXAUTH, CM_INV },
  580. #endif /* CK_AUTHENTICATION */
  581. #endif /* CK_KERBEROS */
  582. #endif /* NOSPL */
  583. #ifndef NOFRILLS
  584. { "back", XXBACK, 0 }, /* BACK to previous directory */
  585. #else
  586. { "back", XXNOTAV,CM_INV },
  587. #endif /* NOFRILLS */
  588. { "beep", XXBEEP,CM_INV }, /* BEEP */
  589. #ifndef NOXFER
  590. { "binary", XXBIN, CM_INV }, /* == SET FILE TYPE BINARY */
  591. #endif /* NOXFER */
  592. #ifndef NOFRILLS
  593. { "bug", XXBUG, CM_INV }, /* BUG report instructions */
  594. #else
  595. { "bug", XXNOTAV, CM_INV },
  596. #endif /* NOFRILLS */
  597. #ifdef BROWSER
  598. { "browse", XXBROWS, CM_PSH|CM_LOC }, /* BROWSE (start browser) */
  599. #else
  600. { "browse", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  601. #endif /* BROWSER */
  602. #ifndef NOXFER
  603. { "bye", XXBYE, 0 }, /* BYE to remote server */
  604. #endif /* NOXFER */
  605. #ifndef NOLOCAL
  606. { "c", XXCON, CM_INV|CM_ABR|CM_LOC }, /* (CONNECT) */
  607. #endif /* NOLOCAL */
  608. #ifndef NOFRILLS
  609. { "cat", XXCAT, CM_INV }, /* Invisible synonym for TYPE */
  610. #endif /* NOFRILLS */
  611. #ifndef NOSPL
  612. #ifndef NOXFER
  613. { "cautious", XXCAU, CM_INV },
  614. #endif /* NOXFER */
  615. #endif /* NOSPL */
  616. { "cd", XXCWD, 0 }, /* Change Directory */
  617. { "cdup", XXCDUP, CM_INV }, /* Change Directory Up */
  618. #ifndef NOXFER
  619. #ifdef PIPESEND
  620. { "cget", XXCGET, CM_INV|CM_PSH }, /* CGET */
  621. #else
  622. { "cget", XXNOTAV, CM_INV|CM_PSH }, /* CGET */
  623. #endif /* PIPESEND */
  624. #endif /* NOXFER */
  625. { "ch", XXCHK, CM_INV|CM_ABR },
  626. { "change", XXCHG, 0 }, /* CHANGE strings in file 2013-04-18 */
  627. { "check", XXCHK, 0 }, /* CHECK for a feature */
  628. #ifdef CK_PERMS
  629. #ifdef UNIX
  630. { "chmod", XXCHMOD, 0 }, /* CHMOD */
  631. #else
  632. { "chmod", XXNOTAV, CM_INV },
  633. #endif /* UNIX */
  634. #else
  635. { "chmod", XXNOTAV, CM_INV },
  636. #endif /* CK_PERMS */
  637. #ifdef CKROOT
  638. { "chroot", XXCHRT, CM_INV }, /* CHROOT */
  639. #endif /* CKROOT */
  640. { "ckermit", XXKERMI, CM_INV }, /* CKERMIT (like KERMIT) */
  641. { "cl", XXCLO, CM_ABR|CM_INV },
  642. #ifndef NOFRILLS
  643. { "clear", XXCLE, 0 }, /* CLEAR input and/or device buffer */
  644. #else
  645. { "clear", XXNOTAV, CM_INV },
  646. #endif /* NOFRILLS */
  647. { "close", XXCLO, 0 }, /* CLOSE a log or other file */
  648. { "cls", XXCLS, CM_INV }, /* Clear Screen (CLS) */
  649. { "comment", XXCOM, CM_INV }, /* Introduce a comment */
  650. #ifndef NOLOCAL
  651. { "connect", XXCON, CM_LOC }, /* Begin terminal connection */
  652. #else
  653. { "connect", XXNOTAV, CM_LOC },
  654. #endif /* NOLOCAL */
  655. { "continue", XXCONT, CM_INV }, /* CONTINUE */
  656. #ifndef NOFRILLS
  657. #ifdef ZCOPY
  658. { "co", XXCPY, CM_INV|CM_ABR },
  659. { "cop", XXCPY, CM_INV|CM_ABR },
  660. { "copy", XXCPY, 0 }, /* COPY a file */
  661. #else
  662. { "copy", XXNOTAV, CM_INV },
  663. #endif /* ZCOPY */
  664. { "copyright", XXCPR, CM_INV }, /* COPYRIGHT */
  665. #ifdef ZCOPY
  666. { "cp", XXCPY, CM_INV }, /* COPY a file */
  667. #endif /* ZCOPY */
  668. #ifndef NOLOCAL
  669. #ifndef OS2
  670. { "cq", XXCQ, CM_INV|CM_LOC }, /* CQ (connect quietly) */
  671. #endif /* OS2 */
  672. #endif /* NOLOCAL */
  673. #ifndef NOXFER
  674. #ifdef PIPESEND
  675. { "creceive", XXCREC,CM_INV|CM_PSH }, /* RECEIVE to a command */
  676. { "csend", XXCSEN,CM_INV|CM_PSH }, /* SEND from command */
  677. #else
  678. { "creceive", XXNOTAV,CM_INV|CM_PSH },
  679. { "csend", XXNOTAV,CM_INV|CM_PSH },
  680. #endif /* PIPESEND */
  681. #endif /* NOXFER */
  682. #endif /* NOFRILLS */
  683. { "cwd", XXCWD, CM_INV }, /* Traditional synonym for cd */
  684. #ifndef NOSPL
  685. { "date", XXDATE, 0 }, /* DATE */
  686. { "dcl", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */
  687. { "debug", XXDEBUG, 0 }, /* Print a debugging msg [9.0] */
  688. { "declare", XXDCL, CM_INV }, /* DECLARE an array (see ARRAY) */
  689. { "decrement", XXDEC, 0 }, /* DECREMENT a numeric variable */
  690. { "define", XXDEF, 0 }, /* DEFINE a macro or variable */
  691. #else
  692. { "date", XXNOTAV, CM_INV },
  693. { "dcl", XXNOTAV, CM_INV },
  694. { "declare", XXNOTAV, CM_INV },
  695. { "decrement", XXNOTAV, CM_INV },
  696. { "define", XXNOTAV, CM_INV },
  697. #endif /* NOSPL */
  698. #ifndef NOFRILLS
  699. { "delete", XXDEL, 0 }, /* DELETE a file */
  700. #else
  701. { "delete", XXNOTAV, CM_INV },
  702. #endif /* NOFRILLS */
  703. #ifndef NODIAL
  704. { "dial", XXDIAL, CM_LOC }, /* DIAL a phone number */
  705. #else
  706. { "dial", XXNOTAV, CM_INV|CM_LOC },
  707. #endif /* NODIAL */
  708. #ifdef NT
  709. { "dialer", XXDIALER, CM_INV }, /* K95 Dialer */
  710. #endif /* NT */
  711. { "directory", XXDIR, 0 }, /* DIRECTORY of files */
  712. #ifndef NOFRILLS
  713. #ifndef NOSERVER
  714. { "disable", XXDIS, 0 }, /* DISABLE a server function */
  715. #else
  716. { "disable", XXNOTAV, CM_INV },
  717. #endif /* NOSERVER */
  718. #endif /* NOFRILLS */
  719. #ifndef NOSPL
  720. { "do", XXDO, 0 }, /* DO (execute) a macro */
  721. #else
  722. { "do", XXNOTAV, CM_INV },
  723. #endif /* NOSPL */
  724. { "e", XXEXI, CM_INV|CM_ABR },
  725. #ifndef NOFRILLS
  726. #ifndef NOXFER
  727. { "e-packet", XXERR, CM_INV }, /* Send an Error-Packet */
  728. #endif /* NOXFER */
  729. #endif /* NOFRILLS */
  730. { "echo", XXECH, 0 }, /* ECHO text */
  731. #ifndef NOFRILLS
  732. #ifndef NOPUSH
  733. { "edit", XXEDIT, CM_PSH }, /* EDIT */
  734. #else
  735. { "edit", XXNOTAV, CM_INV|CM_PSH }, /* EDIT */
  736. #endif /* NOPUSH */
  737. #endif /* NOFRILLS */
  738. { "eightbit", XXEIGHT, CM_INV }, /* EIGHTBIT */
  739. #ifndef NOSPL
  740. { "else", XXELS, CM_INV }, /* ELSE part of IF statement */
  741. #else
  742. { "else", XXNOTAV, CM_INV }, /* ELSE part of IF statement */
  743. #endif /* NOSPL */
  744. #ifndef NOSERVER
  745. #ifndef NOFRILLS
  746. { "enable", XXENA, 0 }, /* ENABLE a server function */
  747. #else
  748. { "enable", XXNOTAV, CM_INV },
  749. #endif /* NOFRILLS */
  750. #endif /* NOSERVER */
  751. #ifndef NOSPL
  752. { "end", XXEND, 0 }, /* END command file or macro */
  753. #else
  754. { "end", XXNOTAV, CM_INV },
  755. #endif /* NOSPL */
  756. { "erase", XXDEL, CM_INV }, /* Synonym for DELETE */
  757. #ifndef NOSPL
  758. { "evaluate", XXEVAL, 0 }, /* EVALUATE */
  759. #else
  760. { "evaluate", XXNOTAV, CM_INV },
  761. #endif /* NOSPL */
  762. { "ex", XXEXI, CM_INV|CM_ABR }, /* Let "ex" still be EXIT */
  763. #ifdef CKEXEC
  764. { "exec", XXEXEC, CM_INV|CM_LOC }, /* exec() */
  765. #else
  766. { "exec", XXNOTAV, CM_INV|CM_LOC },
  767. #endif /* CKEXEC */
  768. { "exit", XXEXI, 0 }, /* EXIT from C-Kermit */
  769. { "extended-options", XXXOPTS,CM_INV|CM_HLP }, /* Extended-Options */
  770. #ifdef OS2
  771. { "extproc", XXCOM, CM_INV }, /* Dummy command for OS/2 */
  772. #endif /* OS2 */
  773. #ifndef NOXFER
  774. { "f", XXFIN, CM_INV|CM_ABR }, /* Invisible abbrev for FIN */
  775. #endif /* NOXFER */
  776. #ifndef NOSPL
  777. { "fail", XXFAIL, CM_INV }, /* FAIL */
  778. #ifndef NOXFER
  779. { "fast", XXFAST, CM_INV },
  780. #endif /* NOXFER */
  781. #ifdef CKCHANNELIO
  782. { "fclose", XXF_CL, CM_INV }, /* FCLOSE */
  783. { "fcount", XXF_CO, CM_INV }, /* FCOUNT */
  784. { "fflush", XXF_FL, CM_INV }, /* FFLUSH */
  785. #endif /* CKCHANNELIO */
  786. #ifndef NOXFER
  787. { "fi", XXFIN, CM_INV|CM_ABR }, /* FINISH */
  788. #endif /* NOXFER */
  789. #ifdef CKCHANNELIO
  790. { "file", XXFILE, 0 }, /* FILE */
  791. #endif /* CKCHANNELIO */
  792. #endif /* NOSPL */
  793. #ifndef NOXFER
  794. { "fin", XXFIN, CM_INV|CM_ABR }, /* FINISH */
  795. #endif /* NOXFER */
  796. #ifndef UNIXOROSK
  797. { "find", XXGREP, 0 }, /* FIND (grep) */
  798. #else
  799. { "find", XXGREP,CM_INV },
  800. #endif /* UNIXOROSK */
  801. #ifndef NOXFER
  802. { "finish", XXFIN, 0 }, /* FINISH */
  803. #endif /* NOXFER */
  804. #ifdef TCPSOCKET
  805. { "firewall", XXFIREW, CM_INV|CM_HLP },
  806. #endif /* TCPSOCKET */
  807. #ifdef CKCHANNELIO
  808. { "flist", XXF_LI, CM_INV }, /* FLIST */
  809. { "fopen", XXF_OP, CM_INV }, /* FOPEN */
  810. #endif /* CKCHANNELIO */
  811. #ifndef NOSPL
  812. { "fo", XXFOR, CM_INV|CM_ABR }, /* Invisible abbrev for... */
  813. { "for", XXFOR, 0 }, /* FOR loop */
  814. { "forward", XXFWD, CM_INV }, /* FORWARD */
  815. #endif /* NOSPL */
  816. #ifndef NOFRILLS
  817. { "fot", XXDIR, CM_INV }, /* "fot" = "dir" (for Chris) */
  818. #endif /* NOFRILLS */
  819. #ifdef CKCHANNELIO
  820. { "fread", XXF_RE, CM_INV }, /* FREAD */
  821. { "frewind", XXF_RW, CM_INV }, /* FREWIND */
  822. { "fseek", XXF_SE, CM_INV }, /* FSEEK */
  823. { "fstatus", XXF_ST, CM_INV }, /* FSTATUS */
  824. #endif /* CKCHANNELIO */
  825. #ifdef TCPSOCKET
  826. #ifndef NOFTP
  827. #ifdef SYSFTP
  828. #ifndef NOPUSH
  829. { "ftp", XXFTP, CM_INV|CM_PSH|CM_LOC }, /* System FTP */
  830. #else
  831. { "ftp", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  832. #endif /* NOPUSH */
  833. #else /* SYSFTP */
  834. { "ftp", XXFTP, 0 }, /* Built-in FTP */
  835. #endif /* SYSFTP */
  836. #else /* NOFTP */
  837. { "ftp", XXNOTAV, CM_INV }, /* No FTP */
  838. #endif /* NOFTP */
  839. #endif /* TCPSOCKET */
  840. #ifndef NOSPL
  841. { "function", XXFUNC, CM_INV|CM_HLP }, /* (for HELP FUNCTION) */
  842. #endif /* NOSPL */
  843. #ifdef CKCHANNELIO
  844. { "fwrite", XXF_WR, CM_INV }, /* FWRITE */
  845. #endif /* CKCHANNELIO */
  846. #ifndef NOXFER
  847. { "g", XXGET, CM_INV|CM_ABR }, /* Invisible abbrev for GET */
  848. #ifndef NOSPL
  849. { "ge", XXGET, CM_INV|CM_ABR }, /* Ditto */
  850. #endif /* NOSPL */
  851. { "get", XXGET, 0 }, /* GET */
  852. #endif /* NOXFER */
  853. #ifndef NOSPL
  854. { "getc", XXGETC, 0 }, /* GETC */
  855. #ifdef OS2
  856. { "getkeycode", XXGETK, 0 }, /* GETKEYCODE */
  857. #endif /* OS2 */
  858. #ifndef NOFRILLS
  859. { "getok", XXGOK, 0 }, /* GETOK (ask for Yes/No/OK) */
  860. #endif /* NOFRILLS */
  861. #endif /* NOSPL */
  862. #ifndef NOSPL
  863. { "goto", XXGOTO,0 }, /* GOTO label in take file or macro */
  864. #endif /* NOSPL */
  865. #ifdef UNIXOROSK
  866. { "grep", XXGREP,0 }, /* GREP (find) */
  867. #else
  868. { "grep", XXGREP,CM_INV }, /* GREP (find) */
  869. #endif /* UNIXOROSK */
  870. { "h", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  871. { "he", XXHLP, CM_INV|CM_ABR }, /* Invisible synonym for HELP */
  872. #ifndef NOFRILLS
  873. { "head", XXHEAD, 0 },
  874. #endif /* NOFRILLS */
  875. #ifndef NOLOCAL
  876. { "hangup", XXHAN, CM_LOC }, /* HANGUP the connection */
  877. #endif /* NOLOCAL */
  878. { "hdirectory", XXHDIR, CM_INV }, /* DIR sorted by size biggest first */
  879. { "HELP", XXHLP, 0 }, /* Display HELP text */
  880. #ifndef NOHTTP
  881. #ifdef TCPSOCKET
  882. { "http", XXHTTP, 0 }, /* HTTP operations */
  883. #endif /* TCPSOCKET */
  884. #endif /* NOHTTP */
  885. #ifndef NOSPL
  886. { "i", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  887. { "if", XXIF, 0 }, /* IF ( condition ) command */
  888. #ifdef TCPSOCKET
  889. { "iksd", XXIKSD, CM_INV }, /* Make connection to IKSD */
  890. #else
  891. { "iksd", XXNOTAV, CM_INV },
  892. #endif /* TCPSOCKET */
  893. { "in", XXINP, CM_INV|CM_ABR }, /* Invisible synonym for INPUT */
  894. { "increment", XXINC, 0 }, /* Increment a numeric variable */
  895. { "input", XXINP, 0 }, /* INPUT text from comm device */
  896. #endif /* NOSPL */
  897. #ifndef NOHELP
  898. { "int", XXINT, CM_INV|CM_ABR },
  899. { "intr", XXINT, CM_INV|CM_ABR },
  900. { "INTRO", XXINT, 0 },
  901. { "introduction",XXINT, CM_INV }, /* Print introductory text */
  902. #else
  903. { "intro", XXNOTAV, CM_INV },
  904. { "introduction",XXNOTAV, CM_INV },
  905. #endif /* NOHELP */
  906. #ifdef OS2
  907. { "k95", XXKERMI, CM_INV }, /* Hmmm what's this... */
  908. #endif /* OS2 */
  909. #ifndef NOSPL
  910. { "kcd", XXKCD, 0 },
  911. #endif /* NOSPL */
  912. { "kermit", XXKERMI, CM_INV },
  913. #ifdef OS2
  914. #ifndef NOKVERBS
  915. { "kverb", XXKVRB, CM_INV|CM_HLP }, /* Keyboard verb */
  916. #endif /* NOKVERBS */
  917. #endif /* OS2 */
  918. #ifndef NOFRILLS
  919. { "l", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
  920. #endif /* NOFRILLS */
  921. { "lcd", XXLCWD, CM_INV },
  922. { "lcdup", XXLCDU, CM_INV },
  923. { "lcwd", XXLCWD, CM_INV },
  924. { "ldelete", XXLDEL, CM_INV },
  925. { "ldirectory", XXLDIR, CM_INV },
  926. #ifdef CKLEARN
  927. { "learn", XXLEARN, 0 }, /* LEARN - automatic script writing */
  928. #else
  929. { "learn", XXNOTAV, CM_INV },
  930. #endif /* CKLEARN */
  931. { "li", XXLNOUT, CM_INV|CM_ABR },
  932. { "LICENSE", XXCPR, 0 }, /* LICENSE */
  933. #ifndef NOSPL
  934. { "lineout", XXLNOUT, 0 }, /* LINEOUT = OUTPUT + eol */
  935. #endif /* NOSPL */
  936. #ifdef NT
  937. { "link", XXLINK, 0 }, /* LINK source destination */
  938. #endif /* NT */
  939. { "lmkdir", XXLMKD, CM_INV },
  940. { "lmv", XXLREN, CM_INV },
  941. #ifndef NOFRILLS
  942. { "lo", XXLOG, CM_INV|CM_ABR }, /* Invisible synonym for log */
  943. #endif /* NOFRILLS */
  944. #ifndef NOSPL
  945. { "local", XXLOCAL, CM_INV }, /* LOCAL variable declaration */
  946. #else
  947. { "local", XXNOTAV, CM_INV },
  948. #endif /* NOSPL */
  949. { "locus", XXLOCU, CM_INV|CM_HLP }, /* "help locus" */
  950. { "log", XXLOG, 0 }, /* Open a log file */
  951. { "login", XXLOGIN, 0 }, /* (REMOTE) LOGIN to server or IKSD */
  952. { "logout", XXLOGOUT, 0 }, /* LOGOUT from server or IKSD */
  953. #ifndef NOFRILLS
  954. #ifndef NODIAL
  955. { "lookup", XXLOOK, 0 }, /* LOOKUP */
  956. #else
  957. { "lookup", XXNOTAV, CM_INV },
  958. #endif /* NODIAL */
  959. { "lpwd", XXLPWD, CM_INV },
  960. { "lrename", XXLREN, CM_INV },
  961. { "lrmdir", XXLRMD, CM_INV },
  962. #ifdef UNIXOROSK
  963. { "ls", XXLS, CM_INV|CM_PSH }, /* UNIX ls command */
  964. #else
  965. { "ls", XXDIR, CM_INV }, /* Invisible synonym for DIR */
  966. #endif /* UNIXOROSK */
  967. #ifndef NOXFER
  968. { "mail", XXMAI, 0 }, /* Send a file as e-mail */
  969. #endif /* NOXFER */
  970. #ifndef NOHELP
  971. { "manual", XXMAN, CM_PSH }, /* MAN(UAL) */
  972. #else
  973. { "manual", XXNOTAV, CM_INV|CM_PSH },
  974. #endif /* NOHELP */
  975. #endif /* NOFRILLS */
  976. #ifdef CK_MKDIR
  977. { "md", XXMKDIR, CM_INV }, /* Synonym for MKDIR */
  978. #endif /* CK_MKDIR */
  979. { "message", XXMSG, 0 }, /* Print debugging message */
  980. #ifdef CK_MINPUT
  981. { "minput", XXMINP, 0 }, /* MINPUT */
  982. #else
  983. { "minput", XXNOTAV, CM_INV },
  984. #endif /* CK_MINPUT */
  985. #ifndef NOMSEND
  986. { "mget", XXMGET, 0 }, /* MGET */
  987. #else
  988. { "mget", XXNOTAV, CM_INV },
  989. #endif /* NOMSEND */
  990. #ifdef CK_MKDIR
  991. { "mkdir", XXMKDIR, 0 }, /* MKDIR */
  992. #else
  993. { "mkdir", XXNOTAV, CM_INV },
  994. #endif /* CK_MKDIR */
  995. #ifndef NOXFER
  996. #ifndef NOMSEND
  997. { "mmove", XXMMOVE, 0 }, /* MMOVE */
  998. #else
  999. { "mmove", XXNOTAV, CM_INV },
  1000. #endif /* NOMSEND */
  1001. #endif /* NOXFER */
  1002. #ifndef NOFRILLS
  1003. { "more", XXMORE, CM_INV }, /* MORE */
  1004. #endif /* NOFRILLS */
  1005. #ifdef OLDMOVE
  1006. #ifndef NOXFER
  1007. { "move", XXMOVE, 0 }, /* MOVE = SEND /DELETE */
  1008. #endif /* NOXFER */
  1009. #else
  1010. { "move", XXREN, CM_INV }, /* MOVE = RENAME */
  1011. #endif /* OLDMOVE */
  1012. #ifndef NOSPL
  1013. { "mpause", XXMSL, CM_INV }, /* Millisecond sleep */
  1014. #else
  1015. { "mpause", XXNOTAV, CM_INV },
  1016. #endif /* NOSPL */
  1017. #ifndef NOXFER
  1018. #ifndef NOMSEND
  1019. { "mput", XXMSE, CM_INV }, /* MPUT = MSEND */
  1020. { "ms", XXMSE, CM_INV|CM_ABR },
  1021. { "msend", XXMSE, 0 }, /* Multiple SEND */
  1022. #else
  1023. { "mput", XXNOTAV, CM_INV },
  1024. { "msend", XXNOTAV, CM_INV },
  1025. #endif /* NOMSEND */
  1026. #endif /* NOXFER */
  1027. { "msg", XXMSG, CM_INV }, /* Print debugging message */
  1028. #ifndef NOSPL
  1029. { "msleep", XXMSL, 0 }, /* Millisecond sleep */
  1030. #else
  1031. { "msleep", XXNOTAV, CM_INV },
  1032. #endif /* NOSPL */
  1033. #ifndef NOFRILLS
  1034. { "mv", XXREN, CM_INV }, /* Synonym for rename */
  1035. #endif /* NOFRILLS */
  1036. #ifndef NOHELP
  1037. { "news", XXNEW, CM_INV }, /* Display NEWS of new features */
  1038. #else
  1039. { "news", XXNOTAV, CM_INV },
  1040. #endif /* NOHELP */
  1041. { "nolocal", XXNLCL, CM_INV }, /* Disable SET LINE / SET HOST */
  1042. { "nopush", XXNPSH, CM_INV }, /* Disable PUSH command/features */
  1043. #ifdef OS2
  1044. { "noscroll", XXNSCR, CM_INV }, /* Disable scroll operations */
  1045. #endif /* OS2 */
  1046. #ifndef NOSPL
  1047. { "o", XXOUT, CM_INV|CM_ABR }, /* Invisible synonym for OUTPUT */
  1048. { "open", XXOPE, 0 }, /* OPEN file for reading or writing */
  1049. #else
  1050. { "open", XXOPE, CM_INV }, /* OPEN */
  1051. #endif /* NOSPL */
  1052. #ifndef NOHELP
  1053. { "options", XXOPTS,CM_INV|CM_HLP }, /* Options */
  1054. #endif /* NOHELP */
  1055. { "orientation", XXORIE, 0 },
  1056. #ifndef NOSPL
  1057. { "output", XXOUT, 0 }, /* OUTPUT text to comm device */
  1058. #else
  1059. { "output", XXNOTAV, CM_INV },
  1060. #endif /* NOSPL */
  1061. #ifdef ANYX25
  1062. #ifndef IBMX25
  1063. { "pad", XXPAD, CM_LOC }, /* X.3 PAD commands */
  1064. #endif /* IBMX25 */
  1065. #endif /* ANYX25 */
  1066. #ifdef NEWFTP
  1067. { "passive", XXPASV, CM_INV }, /* (FTP) PASSIVE */
  1068. #endif /* NEWFTP */
  1069. #ifndef NOHELP
  1070. { "patterns", XXPAT,CM_INV|CM_HLP }, /* Pattern syntax */
  1071. #endif /* NOHELP */
  1072. #ifndef NOSPL
  1073. { "pause", XXPAU, 0 }, /* Sleep for specified interval */
  1074. #else
  1075. { "pause", XXNOTAV, CM_INV },
  1076. #endif /* NOSPL */
  1077. #ifndef NODIAL
  1078. { "pdial", XXPDIA, CM_LOC }, /* PDIAL (partial dial) */
  1079. #else
  1080. { "pdial", XXNOTAV, CM_INV|CM_LOC },
  1081. #endif /* NODIAL */
  1082. #ifdef TCPSOCKET
  1083. #ifndef NOPUSH
  1084. { "ping", XXPNG, CM_INV|CM_PSH|CM_LOC }, /* PING */
  1085. #else
  1086. { "ping", XXNOTAV, CM_INV|CM_PSH|CM_LOC },
  1087. #endif /* NOPUSH */
  1088. #endif /* TCPSOCKET */
  1089. #ifdef NETCMD
  1090. #ifndef NOPUSH
  1091. { "pipe", XXPIPE, CM_PSH }, /* PIPE */
  1092. #else
  1093. { "pipe", XXNOTAV, CM_INV|CM_PSH }, /* PIPE */
  1094. #endif /* NOPUSH */
  1095. #endif /* NETCMD */
  1096. #ifndef NOSPL
  1097. { "pop", XXEND, CM_INV }, /* Invisible synonym for END */
  1098. #endif /* NOSPL */
  1099. #ifndef NOFRILLS
  1100. { "print", XXPRI, 0 }, /* PRINT a file locally */
  1101. #endif /* NOFRILLS */
  1102. { "prompt", XXPROMP, CM_INV }, /* Go interactive (from script) */
  1103. #ifndef NOXFER
  1104. #ifdef CK_RESEND
  1105. { "psend", XXPSEN, CM_INV }, /* PSEND */
  1106. #else
  1107. { "psend", XXNOTAV, CM_INV },
  1108. #endif /* CK_RESEND */
  1109. #endif /* NOXFER */
  1110. #ifdef NETPTY
  1111. { "pty", XXPTY, CM_PSH }, /* PTY */
  1112. #else
  1113. { "pty", XXNOTAV, CM_INV|CM_PSH },
  1114. #endif /* NETPTY */
  1115. #ifndef NOPUSH
  1116. { "pu", XXSHE, CM_INV|CM_ABR|CM_PSH }, /* PU = PUSH */
  1117. #endif /* NOPUSH */
  1118. #ifdef CKPURGE
  1119. { "purge", XXPURGE, 0 }, /* PURGE (real) */
  1120. #else
  1121. #ifdef VMS
  1122. { "purge", XXPURGE, 0 }, /* PURGE (fake) */
  1123. #else
  1124. { "purge", XXNOTAV, CM_INV },
  1125. #endif /* VMS */
  1126. #endif /* CKPURGE */
  1127. #ifndef NOPUSH
  1128. { "push", XXSHE, CM_PSH }, /* PUSH command (like RUN, !) */
  1129. #else
  1130. { "push", XXNOTAV, CM_INV|CM_PSH },
  1131. #endif /* NOPUSH */
  1132. #ifndef NOXFER
  1133. { "put", XXSEN, CM_INV }, /* PUT = SEND */
  1134. #endif /* NOXFER */
  1135. #ifdef UNIX
  1136. #ifndef NOPUTENV
  1137. { "putenv", XXPUTE, CM_INV }, /* PUTENV */
  1138. #endif /* NOPUTENV */
  1139. #endif /* UNIX */
  1140. { "pwd", XXPWD, 0 }, /* Print Working Directory */
  1141. { "q", XXQUI, CM_INV|CM_ABR }, /* Invisible synonym for QUIT */
  1142. #ifndef NOXFER
  1143. { "query", XXRQUE,CM_INV }, /* (= REMOTE QUERY) */
  1144. #endif /* NOXFER */
  1145. { "quit", XXQUI, 0 }, /* QUIT from program = EXIT */
  1146. #ifndef NOXFER
  1147. { "r", XXREC, CM_INV|CM_ABR }, /* Inv synonym for RECEIVE */
  1148. #endif /* NOXFER */
  1149. #ifndef NOXFER
  1150. { "rasg", XXRASG, CM_INV }, /* REMOTE ASSIGN */
  1151. { "rassign", XXRASG, CM_INV }, /* ditto */
  1152. { "rcd", XXRCWD, CM_INV }, /* REMOTE CD */
  1153. { "rcdup", XXRCDUP,CM_INV }, /* REMOTE CD */
  1154. { "rcopy", XXRCPY, CM_INV }, /* REMOTE COPY */
  1155. { "rcwd", XXRCWD, CM_INV }, /* REMOTE CWD */
  1156. { "rdelete", XXRDEL, CM_INV }, /* REMOTE DELETE */
  1157. { "rdirectory", XXRDIR, CM_INV }, /* REMODE DIRECTORY */
  1158. #endif /* NOXFER */
  1159. #ifndef NOSPL
  1160. { "read", XXREA, 0 }, /* READ a line from a file */
  1161. #else
  1162. { "read", XXNOTAV, CM_INV },
  1163. #endif /* NOSPL */
  1164. #ifndef NOXFER
  1165. { "receive", XXREC, 0 }, /* RECEIVE files */
  1166. #endif /* NOXFER */
  1167. #ifndef NODIAL
  1168. { "red", XXRED, CM_INV|CM_ABR|CM_LOC }, /* Inv syn for REDIAL */
  1169. { "redi", XXRED, CM_INV|CM_ABR|CM_LOC }, /* ditto */
  1170. { "redial", XXRED, CM_LOC }, /* REDIAL last DIAL number */
  1171. #else
  1172. { "red", XXNOTAV, CM_INV|CM_LOC },
  1173. { "redi", XXNOTAV, CM_INV|CM_LOC },
  1174. { "redial", XXNOTAV, CM_INV|CM_LOC },
  1175. #endif /* NODIAL */
  1176. #ifdef CK_REDIR
  1177. #ifdef OS2
  1178. #ifndef NOPUSH
  1179. { "redirect", XXFUN, CM_INV|CM_PSH }, /* REDIRECT */
  1180. #else
  1181. { "redirect", XXNOTAV, CM_INV|CM_PSH },
  1182. #endif /* NOPUSH */
  1183. #else /* OS2 */
  1184. #ifndef NOPUSH
  1185. { "redirect", XXFUN, CM_PSH }, /* REDIRECT */
  1186. #else
  1187. { "redirect", XXNOTAV, CM_INV|CM_PSH },
  1188. #endif /* NOPUSH */
  1189. #endif /* OS2 */
  1190. #endif /* CK_REDIR */
  1191. #ifdef CK_RECALL
  1192. { "redo", XXREDO, CM_NOR }, /* REDO */
  1193. #else
  1194. { "redo", XXNOTAV, CM_INV },
  1195. #endif /* CK_RECALL */
  1196. #ifndef NOXFER
  1197. #ifdef CK_RESEND
  1198. { "reget", XXREGET, 0 }, /* REGET */
  1199. #else
  1200. { "reget", XXNOTAV, CM_INV },
  1201. #endif /* CK_RESEND */
  1202. #endif /* NOXFER */
  1203. #ifndef NOSPL
  1204. { "reinput", XXREI, CM_INV }, /* REINPUT (from INPUT buffer) */
  1205. #else
  1206. { "reinput", XXNOTAV, CM_INV },
  1207. #endif /* NOSPL */
  1208. #ifndef NOXFER
  1209. #ifdef ADDCMD
  1210. { "rem", XXREM, CM_INV|CM_ABR },
  1211. { "remo", XXREM, CM_INV|CM_ABR },
  1212. #endif /* ADDCMD */
  1213. { "remote", XXREM, 0 }, /* Send REMOTE command to server */
  1214. #endif /* NOXFER */
  1215. #ifdef ADDCMD
  1216. { "remove", XXREMV,0 }, /* REMOVE (something from a list) */
  1217. #else
  1218. { "remove", XXNOTAV, CM_INV },
  1219. #endif /* ADDCMD */
  1220. #ifndef NOFRILLS
  1221. #ifndef NORENAME
  1222. { "rename", XXREN, 0 }, /* RENAME a local file */
  1223. #else
  1224. { "rename", XXNOTAV, CM_INV },
  1225. #endif /* NORENAME */
  1226. { "replay", XXTYP, CM_INV }, /* REPLAY (for now, just type) */
  1227. #endif /* NOFRILLS */
  1228. #ifndef NOXFER
  1229. #ifdef CK_RESEND
  1230. { "rep", XXTYP, CM_INV|CM_ABR }, /* REPLAY abbreviation */
  1231. { "reput", XXRSEN, CM_INV }, /* REPUT = RESEND */
  1232. { "res", XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1233. { "rese", XXRSEN, CM_INV|CM_ABR }, /* RESEND */
  1234. { "resend", XXRSEN, 0 }, /* RESEND */
  1235. #else
  1236. { "reput", XXNOTAV, CM_INV },
  1237. { "res", XXNOTAV, CM_INV },
  1238. { "rese", XXNOTAV, CM_INV },
  1239. { "resend", XXNOTAV, CM_INV },
  1240. #endif /* CK_RESEND */
  1241. #endif /* NOXFER */
  1242. { "reset", XXRESET, CM_INV }, /* RESET */
  1243. #ifdef CK_RESEND
  1244. #ifndef NOSPL
  1245. { "ret", XXRET, CM_INV|CM_ABR },
  1246. #endif /* NOSPL */
  1247. #endif /* CK_RESEND */
  1248. #ifndef NOXFER
  1249. { "retrieve", XXRETR, CM_INV }, /* RETRIEVE */
  1250. #endif /* NOXFER */
  1251. #ifndef NOSPL
  1252. { "return", XXRET, 0 }, /* RETURN from a function */
  1253. #else
  1254. { "return", XXNOTAV, CM_INV },
  1255. #endif /* NOSPL */
  1256. #ifndef NOXFER
  1257. { "rexit", XXRXIT, CM_INV }, /* REMOTE EXIT */
  1258. #endif /* NOXFER */
  1259. #ifdef CK_REXX
  1260. #ifndef NOPUSH
  1261. { "rexx", XXREXX, CM_PSH }, /* Execute a Rexx command */
  1262. #else
  1263. { "rexx", XXNOTAV, CM_INV|CM_PSH },
  1264. #endif /* NOPUSH */
  1265. #endif /* CK_REXX */
  1266. #ifndef NOXFER
  1267. { "rhelp", XXRHLP, CM_INV }, /* REMOTE HELP */
  1268. { "rhost", XXRHOS, CM_INV }, /* REMOTE HOST */
  1269. { "rkermit", XXRKER, CM_INV }, /* REMOTE KERMIT */
  1270. #endif /* NOXFER */
  1271. #ifdef TCPSOCKET
  1272. { "rlogin", XXRLOG, CM_LOC }, /* Make an Rlogin connection */
  1273. #else
  1274. { "rlogin", XXNOTAV, CM_INV|CM_LOC },
  1275. #endif /* TCPSOCKET */
  1276. #ifndef NOFRILLS
  1277. { "rm", XXDEL, CM_INV }, /* Invisible synonym for delete */
  1278. #endif /* NOFRILLS */
  1279. #ifdef CK_MKDIR
  1280. { "rmdir", XXRMDIR, 0 }, /* RMDIR */
  1281. #else
  1282. { "rmdir", XXNOTAV, CM_INV },
  1283. #endif /* CK_MKDIR */
  1284. #ifndef NOXFER
  1285. { "rmessage", XXRMSG, CM_INV }, /* REMOTE MESSAGE */
  1286. { "rmkdir", XXRMKD, CM_INV }, /* REMOTE MKDIR */
  1287. { "rmsg", XXRMSG, CM_INV }, /* REMOTE MESSAGE */
  1288. #ifndef NOSPL
  1289. { "robust", XXROB, CM_INV },
  1290. #else
  1291. { "robust", XXNOTAV, CM_INV },
  1292. #endif /* NOSPL */
  1293. { "rprint", XXRPRI, CM_INV }, /* REMOTE PRINT */
  1294. { "rpwd", XXRPWD, CM_INV }, /* REMOTE PWD */
  1295. { "rquery", XXRQUE, CM_INV }, /* REMOTE QUERY */
  1296. #endif /* NOXFER */
  1297. #ifdef CK_RECALL
  1298. { "rr", XXREDO, CM_INV|CM_NOR },
  1299. #endif /* CK_RECALL */
  1300. #ifndef NOXFER
  1301. { "rrename", XXRREN, CM_INV }, /* REMOTE RENAME */
  1302. { "rrmdir", XXRRMD, CM_INV }, /* REMOTE REMDIR */
  1303. { "rset", XXRSET, CM_INV }, /* REMOTE SET */
  1304. { "rspace", XXRSPA, CM_INV }, /* REMOTE SPACE */
  1305. { "rtype", XXRTYP, CM_INV }, /* REMOTE TYPE */
  1306. #endif /* NOXFER */
  1307. #ifndef NOPUSH
  1308. { "run", XXSHE, CM_PSH }, /* RUN a program or command */
  1309. #else
  1310. { "run", XXNOTAV, CM_INV|CM_PSH },
  1311. #endif /* NOPUSH */
  1312. #ifndef NOXFER
  1313. { "rwho", XXRWHO, CM_INV }, /* REMOTE WHO */
  1314. { "s", XXSEN, CM_INV|CM_ABR }, /* Invisible synonym for send */
  1315. #endif /* NOXFER */
  1316. #ifndef NOSETKEY
  1317. #ifdef OS2
  1318. { "save", XXSAVE, 0 }, /* SAVE something */
  1319. #else
  1320. { "save", XXSAVE, CM_INV },
  1321. #endif /* OS2 */
  1322. #else
  1323. { "save", XXNOTAV, CM_INV },
  1324. #endif /* NOSETKEY */
  1325. #ifndef NOSCRIPT
  1326. { "sc", XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1327. { "scr", XXLOGI, CM_INV|CM_ABR|CM_LOC },
  1328. #endif /* NOSCRIPT */
  1329. { "screen", XXSCRN, 0 }, /* SCREEN actions */
  1330. #ifndef NOSCRIPT
  1331. { "script", XXLOGI, CM_LOC }, /* Expect-Send-style script line */
  1332. #else
  1333. { "script", XXNOTAV, CM_INV|CM_LOC },
  1334. #endif /* NOSCRIPT */
  1335. { "search", XXGREP,CM_INV }, /* Synonym for GREP and FIND */
  1336. #ifndef NOXFER
  1337. { "send", XXSEN, 0 }, /* Send (a) file(s) */
  1338. #ifndef NOSERVER
  1339. { "server", XXSER, 0 }, /* Be a SERVER */
  1340. #else
  1341. { "server", XXNOTAV, CM_INV },
  1342. #endif /* NOSERVER */
  1343. #endif /* NOXFER */
  1344. { "set", XXSET, 0 }, /* SET parameters */
  1345. #ifndef NOSPL
  1346. #ifndef NOSEXP
  1347. { "sexpression", XXSEXP, CM_INV|CM_HLP }, /* SEXPR */
  1348. #endif /* NOSEXP */
  1349. #ifdef SFTP_BUILTIN
  1350. { "sftp", XXSFTP, 0 }, /* SFTP */
  1351. #endif /* SFTP_BUILTIN */
  1352. #ifndef NOSHOW
  1353. { "sh", XXSHO, CM_INV|CM_ABR }, /* SHOW parameters */
  1354. #endif /* NOSHOW */
  1355. { "shift", XXSHIFT, 0 }, /* SHIFT args */
  1356. #else
  1357. { "shift", XXNOTAV, CM_INV },
  1358. #endif /* NOSPL */
  1359. #ifndef NOSHOW
  1360. { "show", XXSHO, 0 }, /* SHOW parameters */
  1361. #else
  1362. { "show", XXNOTAV, CM_INV },
  1363. #endif /* NOSHOW */
  1364. #ifdef NEWFTP
  1365. { "site", XXSITE, CM_INV }, /* (FTP) SITE */
  1366. #endif /* NEWFTP */
  1367. #ifdef SSHBUILTIN
  1368. { "skermit", XXSKRM, 0 }, /* SKERMIT */
  1369. #endif /* SSHBUILTIN */
  1370. #ifndef NOSPL
  1371. #ifndef NOFRILLS
  1372. { "sleep", XXPAU, CM_INV }, /* SLEEP for specified interval */
  1373. #endif /* NOFRILLS */
  1374. #endif /* NOSPL */
  1375. #ifndef NOSPL
  1376. { "sort", XXSORT, CM_INV }, /* (see ARRAY) */
  1377. #else
  1378. { "sort", XXNOTAV, CM_INV },
  1379. #endif /* NOSPL */
  1380. #ifndef MAC
  1381. #ifndef NOFRILLS
  1382. { "sp", XXSPA, CM_INV|CM_ABR },
  1383. { "spa", XXSPA, CM_INV|CM_ABR },
  1384. #endif /* NOFRILLS */
  1385. { "space", XXSPA, 0 }, /* Show available disk SPACE */
  1386. #endif /* MAC */
  1387. #ifndef NOFRILLS
  1388. #ifndef NOPUSH
  1389. { "spawn", XXSHE, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1390. #else
  1391. { "spawn", XXNOTAV, CM_INV|CM_PSH }, /* Synonym for PUSH, RUN */
  1392. #endif /* NOPUSH */
  1393. #endif /* NOFRILLS */
  1394. #ifdef ANYSSH
  1395. { "ssh", XXSSH, 0 },
  1396. #endif /* ANYSSH */
  1397. #ifndef NOXFER
  1398. { "sta", XXSTA, CM_INV|CM_ABR },
  1399. { "stat", XXSTA, CM_INV|CM_ABR },
  1400. { "statistics", XXSTA, 0 }, /* Display file transfer stats */
  1401. #endif /* NOXFER */
  1402. { "status", XXSTATUS,0 }, /* Show status of previous command */
  1403. #ifndef NOSPL
  1404. { "stop", XXSTO, 0 }, /* STOP all take files and macros */
  1405. { "succeed", XXSUCC, CM_INV }, /* SUCCEED */
  1406. #else
  1407. { "stop", XXNOTAV, CM_INV },
  1408. { "succeed", XXNOTAV, CM_INV },
  1409. #endif /* NOSPL */
  1410. #ifndef NOFRILLS
  1411. { "SUPPORT", XXBUG, 0 }, /* Tech support instructions */
  1412. #else
  1413. { "support", XXNOTAV, CM_INV },
  1414. #endif /* NOFRILLS */
  1415. #ifndef NOJC
  1416. { "suspend", XXSUS, CM_PSH }, /* SUSPEND C-Kermit (UNIX only) */
  1417. #else
  1418. { "suspend", XXNOTAV, CM_INV|CM_PSH },
  1419. #endif /* NOJC */
  1420. #ifndef NOSPL
  1421. { "switch", XXSWIT, 0 }, /* SWITCH */
  1422. #else
  1423. { "switch", XXNOTAV, CM_INV },
  1424. #endif /* NOSPL */
  1425. #ifdef CK_TAPI
  1426. { "ta", XXTAK, CM_INV|CM_ABR }, /* (because of TAPI) */
  1427. #endif /* CK_TAPI */
  1428. #ifndef NOFRILLS
  1429. { "tail", XXTAIL, 0 }, /* Display end of a local file */
  1430. #endif /* NOFRILLS */
  1431. { "take", XXTAK, 0 }, /* TAKE commands from a file */
  1432. #ifdef CK_TAPI
  1433. { "tapi", XXTAPI, CM_LOC }, /* Microsoft TAPI commands */
  1434. #else
  1435. { "tapi", XXNOTAV, CM_INV|CM_LOC },
  1436. #endif /* CK_TAPI */
  1437. #ifndef NOFRILLS
  1438. #ifdef TCPSOCKET
  1439. { "tel", XXTEL, CM_INV|CM_ABR|CM_LOC },
  1440. { "telnet", XXTEL, CM_LOC }, /* TELNET (TCP/IP only) */
  1441. { "telopt", XXTELOP, CM_INV }, /* TELOPT (ditto) */
  1442. #else
  1443. { "tel", XXNOTAV, CM_INV|CM_LOC },
  1444. { "telnet", XXNOTAV, CM_INV|CM_LOC },
  1445. { "telopt", XXNOTAV, CM_INV },
  1446. #endif /* TCPSOCKET */
  1447. #ifdef OS2
  1448. { "terminal", XXTERM, CM_INV|CM_LOC }, /* == SET TERMINAL TYPE */
  1449. #else
  1450. { "terminal", XXTERM, CM_INV },
  1451. #endif /* OS2 */
  1452. #endif /* NOFRILLS */
  1453. #ifndef NOXFER
  1454. { "text", XXASC, CM_INV }, /* == SET FILE TYPE TEXT */
  1455. #endif /* NOXFER */
  1456. { "touch", XXTOUC, 0 }, /* TOUCH */
  1457. #ifndef NOSPL
  1458. { "trace", XXTRACE, 0 }, /* TRACE */
  1459. #else
  1460. { "trace", XXNOTAV, CM_INV },
  1461. #endif /* NOSPL */
  1462. #ifndef NOCSETS
  1463. { "translate", XXXLA, 0 }, /* TRANSLATE local file char sets */
  1464. #else
  1465. { "translate", XXNOTAV, CM_INV },
  1466. #endif /* NOCSETS */
  1467. #ifndef NOXMIT
  1468. { "transmit", XXTRA, 0 }, /* Send (upload) a file, no protocol */
  1469. #else
  1470. { "transmit", XXNOTAV, CM_INV },
  1471. #endif /* NOXMIT */
  1472. #ifndef NOFRILLS
  1473. { "type", XXTYP, 0 }, /* Display a local file */
  1474. #endif /* NOFRILLS */
  1475. #ifndef NOSPL
  1476. { "undcl", XXUNDCL, CM_INV },
  1477. { "undeclare", XXUNDCL, 0 }, /* UNDECLARE an array */
  1478. { "undefine", XXUNDEF, 0 }, /* UNDEFINE a variable or macro */
  1479. #else
  1480. { "undcl", XXNOTAV, CM_INV },
  1481. { "undeclare", XXNOTAV, CM_INV },
  1482. { "undefine", XXNOTAV, CM_INV },
  1483. #endif /* NOSPL */
  1484. #ifdef NEWFTP
  1485. { "user", XXUSER, CM_INV }, /* (FTP) USER */
  1486. #endif /* NEWFTP */
  1487. { "version", XXVER, 0 }, /* VERSION-number display */
  1488. #ifdef OS2
  1489. { "viewonly", XXVIEW, CM_LOC }, /* VIEWONLY Terminal Mode */
  1490. #endif /* OS2 */
  1491. { "void", XXVOID, 0 }, /* VOID */
  1492. #ifndef NOSPL
  1493. { "wait", XXWAI, 0 }, /* WAIT */
  1494. #else
  1495. { "wait", XXNOTAV, CM_INV },
  1496. #endif /* NOSPL */
  1497. { "wdirectory", XXWDIR, CM_INV }, /* Like TOPS-20, reverse chron order */
  1498. { "wermit", XXKERMI, CM_INV },
  1499. #ifndef NOXFER
  1500. { "where", XXWHERE, 0 }, /* WHERE (did my file go?) */
  1501. #endif /* NOXFER */
  1502. #ifndef NOSPL
  1503. { "while", XXWHI, 0 }, /* WHILE loop */
  1504. #else
  1505. { "while", XXNOTAV, CM_INV },
  1506. #endif /* NOSPL */
  1507. #ifndef OS2
  1508. #ifndef MAC
  1509. #ifndef NOFRILLS
  1510. { "who", XXWHO, CM_PSH }, /* WHO's logged in? */
  1511. #endif /* NOFRILLS */
  1512. #endif /* MAC */
  1513. #endif /* OS2 */
  1514. #ifndef NOHELP
  1515. { "wildcards", XXWILD,CM_INV|CM_HLP }, /* Wildcard syntax */
  1516. #endif /* NOHELP */
  1517. #ifndef NOSPL
  1518. { "wr", XXWRI, CM_INV|CM_ABR },
  1519. { "wri", XXWRI, CM_INV|CM_ABR },
  1520. { "writ", XXWRI, CM_INV|CM_ABR },
  1521. { "write", XXWRI, 0 }, /* WRITE characters to a file */
  1522. { "write-line", XXWRL, CM_INV }, /* WRITE a line to a file */
  1523. { "writeln", XXWRL, CM_INV }, /* Pascalisch synonym for write-line */
  1524. #else
  1525. { "wr", XXNOTAV, CM_INV },
  1526. { "wri", XXNOTAV, CM_INV },
  1527. { "writ", XXNOTAV, CM_INV },
  1528. { "write", XXNOTAV, CM_INV },
  1529. { "write-line", XXNOTAV, CM_INV },
  1530. { "writeln", XXNOTAV, CM_INV },
  1531. #endif /* NOSPL */
  1532. #ifndef NOFRILLS
  1533. { "xecho", XXXECH,0 }, /* XECHO */
  1534. #endif /* NOFRILLS */
  1535. #ifndef NOSPL
  1536. { "xif", XXIFX, CM_INV }, /* Extended IF command (obsolete) */
  1537. #else
  1538. { "xif", XXNOTAV, CM_INV },
  1539. #endif /* NOSPL */
  1540. #ifndef NOCSETS
  1541. { "xlate", XXXLA, CM_INV }, /* Synonym for TRANSLATE */
  1542. #else
  1543. { "xlate", XXNOTAV, CM_INV },
  1544. #endif /* NOCSETS */
  1545. #ifndef NOXMIT
  1546. { "xm", XXTRA, CM_INV|CM_ABR }, /* Avoid conflict with XMESSAGE */
  1547. #else
  1548. { "xm", XXNOTAV, CM_INV|CM_ABR }, /* Synonym for TRANSMIT */
  1549. #endif /* NOXMIT */
  1550. { "xmessage", XXXMSG, 0 }, /* Print debugging message */
  1551. #ifndef NOXMIT
  1552. { "xmit", XXTRA, CM_INV }, /* Synonym for TRANSMIT */
  1553. #else
  1554. { "xmit", XXNOTAV, CM_INV },
  1555. #endif /* NOXMIT */
  1556. { "xmsg", XXXMSG, CM_INV }, /* Synonym for XMESSAGE */
  1557. #ifndef OS2
  1558. #ifndef NOJC
  1559. { "z", XXSUS, CM_INV|CM_PSH }, /* Synonym for SUSPEND */
  1560. #else
  1561. { "z", XXNOTAV, CM_INV|CM_PSH },
  1562. #endif /* NOJC */
  1563. #endif /* OS2 */
  1564. #ifndef NOSPL
  1565. { "{", XXMACRO, CM_INV }, /* Immediate macro */
  1566. #endif /* NOSPL */
  1567. { "", 0, 0 }
  1568. };
  1569. int ncmd = (sizeof(cmdtab) / sizeof(struct keytab)) - 1;
  1570. /* NOTE: Tokens must also be entered above into cmdtab[]. */
  1571. char toktab[] = {
  1572. #ifndef NOPUSH
  1573. '!', /* Shell escape */
  1574. #endif /* NOPUSH */
  1575. '#', /* Comment */
  1576. #ifndef NOSPL
  1577. '(', /* S-Expression */
  1578. '.', /* Assignment */
  1579. #endif /* NOSPL */
  1580. ';', /* Comment */
  1581. #ifndef NOSPL
  1582. ':', /* Label */
  1583. #endif /* NOSPL */
  1584. #ifndef NOPUSH
  1585. #ifdef CK_REDIR
  1586. '<', /* REDIRECT */
  1587. #endif /* CK_REDIR */
  1588. '@', /* DCL escape */
  1589. #endif /* NOPUSH */
  1590. #ifdef CK_RECALL
  1591. '^', /* Command recall */
  1592. #endif /* CK_RECALL */
  1593. #ifndef NOSPL
  1594. '{', /* Immediate macro */
  1595. #endif /* NOSPL */
  1596. '\0' /* End of this string */
  1597. };
  1598. int xxdot = 0; /* Used with "." token */
  1599. struct keytab yesno[] = { /* Yes/No keyword table */
  1600. { "no", 0, 0 },
  1601. { "ok", 1, 0 },
  1602. { "yes", 1, 0 }
  1603. };
  1604. int nyesno = (sizeof(yesno) / sizeof(struct keytab));
  1605. /* Save keyword table */
  1606. struct keytab savtab[] = {
  1607. #ifdef OS2
  1608. { "command", XSCMD, 0 },
  1609. #else
  1610. #ifdef CK_RECALL
  1611. { "command", XSCMD, 0 },
  1612. #endif /* CK_RECALL */
  1613. #endif /* OS2 */
  1614. #ifndef NOSETKEY
  1615. { "keymap", XSKEY, 0 },
  1616. #endif /* NOSETKEY */
  1617. #ifdef OS2
  1618. { "terminal", XSTERM, 0 },
  1619. #endif /* OS2 */
  1620. { "", 0, 0 }
  1621. };
  1622. int nsav = (sizeof(savtab) / sizeof(struct keytab)) - 1;
  1623. /* Parameter keyword table */
  1624. struct keytab prmtab[] = {
  1625. { "alarm", XYALRM, 0 },
  1626. #ifdef COMMENT /* SET ANSWER not implemented yet */
  1627. #ifndef NODIAL
  1628. { "answer", XYANSWER,0 },
  1629. #endif /* NODIAL */
  1630. #endif /* COMMENT */
  1631. { "ask-timer", XYTIMER, 0 },
  1632. #ifndef NOXFER
  1633. { "attributes", XYATTR, 0 },
  1634. #endif /* NOXFER */
  1635. #ifdef CK_AUTHENTICATION
  1636. { "authentication", XYAUTH, 0 },
  1637. #else /* CK_AUTHENTICATION */
  1638. #ifdef CK_SSL
  1639. { "authentication", XYAUTH, 0 },
  1640. #endif /* CK_SSL */
  1641. #endif /* CK_AUTHENTICATION */
  1642. { "b", XYBACK, CM_INV|CM_ABR|CM_PSH },
  1643. { "ba", XYBACK, CM_INV|CM_ABR|CM_PSH },
  1644. #ifdef VMS
  1645. { "background", XYBACK, CM_INV|CM_PSH },
  1646. { "batch", XYBACK, CM_PSH },
  1647. #else
  1648. { "background", XYBACK, CM_PSH },
  1649. { "batch", XYBACK, CM_INV|CM_PSH },
  1650. #endif /* VMS */
  1651. #ifndef NOLOCAL
  1652. { "baud", XYSPEE, CM_INV|CM_LOC },
  1653. #endif /* NOLOCAL */
  1654. { "bell", XYBELL, 0 },
  1655. #ifndef NOXFER
  1656. { "block-check", XYCHKT, 0 },
  1657. #endif /* NOXFER */
  1658. #ifdef OS2
  1659. #ifdef BPRINT
  1660. { "bprinter", XYBDCP, CM_INV },
  1661. #endif /* BPRINT */
  1662. #endif /* OS2 */
  1663. #ifdef BROWSER
  1664. { "browser", XYBROWSE,CM_PSH|CM_LOC },
  1665. #endif /* BROWSER */
  1666. #ifndef NOXFER
  1667. #ifdef DYNAMIC
  1668. { "buffers", XYBUF, 0 },
  1669. #endif /* DYNAMIC */
  1670. #endif /* NOXFER */
  1671. #ifndef NOLOCAL
  1672. #ifndef MAC
  1673. { "carrier-watch", XYCARR, CM_LOC },
  1674. #endif /* MAC */
  1675. #endif /* NOLOCAL */
  1676. #ifndef NOSPL
  1677. { "case", XYCASE, 0 },
  1678. #endif /* NOSPL */
  1679. { "cd", XYCD, 0 },
  1680. #ifndef NOXFER
  1681. { "cl", XYCLEAR, CM_INV|CM_ABR },
  1682. { "cle", XYCLEAR, CM_INV|CM_ABR },
  1683. { "clea", XYCLEAR, CM_INV|CM_ABR },
  1684. { "clear", XYCLEAR, CM_INV|CM_ABR },
  1685. { "clear-channel", XYCLEAR, 0 },
  1686. { "clearchannel", XYCLEAR, CM_INV },
  1687. #endif /* NOXFER */
  1688. #ifndef NOLOCAL
  1689. { "close-on-disconnect", XYDISC, CM_INV|CM_LOC },
  1690. #endif /* NOLOCAL */
  1691. { "cmd", XYCMD, CM_INV },
  1692. { "command", XYCMD, 0 },
  1693. #ifdef CK_SPEED
  1694. { "con", XYQCTL, CM_INV|CM_ABR },
  1695. #endif /* CK_SPEED */
  1696. { "console", XYCMD, CM_INV },
  1697. #ifdef CK_SPEED
  1698. { "control-character",XYQCTL, 0 },
  1699. #endif /* CK_SPEED */
  1700. #ifndef NOSPL
  1701. { "count", XYCOUN, 0 },
  1702. #endif /* NOSPL */
  1703. #ifndef NOXFER
  1704. { "d", XYDELA, CM_INV|CM_ABR },
  1705. { "de", XYDELA, CM_INV|CM_ABR },
  1706. #endif /* NOXFER */
  1707. { "debug", XYDEBU, 0 },
  1708. #ifdef VMS
  1709. { "default", XYDFLT, 0 },
  1710. #else
  1711. #ifndef MAC
  1712. { "default", XYDFLT, CM_INV },
  1713. #endif /* MAC */
  1714. #endif /* VMS */
  1715. #ifndef NOXFER
  1716. { "delay", XYDELA, 0 },
  1717. { "destination", XYDEST, 0 },
  1718. #endif /* NOXFER */
  1719. #ifndef NODIAL
  1720. { "di", XYDIAL, CM_INV|CM_ABR|CM_LOC },
  1721. { "dia", XYDIAL, CM_INV|CM_ABR|CM_LOC },
  1722. { "dial", XYDIAL, CM_LOC },
  1723. #endif /* NODIAL */
  1724. #ifdef OS2
  1725. { "dialer", XYDLR, CM_INV },
  1726. #endif /* OS2 */
  1727. #ifndef NOLOCAL
  1728. { "disconnect", XYDISC, CM_LOC },
  1729. { "duplex", XYDUPL, CM_LOC },
  1730. #endif /* NOLOCAL */
  1731. #ifndef NOPUSH
  1732. #ifndef NOFRILLS
  1733. { "editor", XYEDIT, CM_PSH },
  1734. #endif /* NOFRILLS */
  1735. #endif /* NOPUSH */
  1736. #ifdef CK_CTRLZ
  1737. { "eof", XYEOF, CM_INV },
  1738. #endif /* CK_CTRLZ */
  1739. #ifndef NOLOCAL
  1740. { "escape-character", XYESC, CM_LOC },
  1741. #endif /* NOLOCAL */
  1742. #ifndef NOSPL
  1743. { "evaluate", XYEVAL, CM_INV },
  1744. #endif /* NOSPL */
  1745. { "exit", XYEXIT, 0 },
  1746. #ifndef NOXFER
  1747. #ifdef CK_XYZ
  1748. #ifndef NOPUSH
  1749. #ifndef XYZ_INTERNAL
  1750. { "external-protocol",XYEXTRN, 0 },
  1751. #endif /* XYZ_INTERNAL */
  1752. #endif /* NOPUSH */
  1753. #endif /* CK_XYZ */
  1754. { "f-ack-bug", XYFACKB, CM_INV },
  1755. { "f-ack-path", XYFACKP, CM_INV },
  1756. #endif /* NOXFER */
  1757. { "file", XYFILE, 0 },
  1758. { "fl", XYFLOW, CM_INV|CM_ABR },
  1759. #ifndef NOSPL
  1760. { "flag", XYFLAG, 0 },
  1761. #endif /* NOSPL */
  1762. #ifdef TCPSOCKET
  1763. #ifndef SYSFTP
  1764. #ifndef NOFTP
  1765. { "ft", XYFTPX, CM_INV|CM_ABR },
  1766. { "ftp", XYFTPX, 0 },
  1767. #endif /* NOFTP */
  1768. #endif /* SYSFTP */
  1769. #endif /* TCPSOCKET */
  1770. #ifdef BROWSER
  1771. { "ftp-client", XYFTP, CM_PSH },
  1772. #endif /* BROWSER */
  1773. { "flow-control", XYFLOW, 0 },
  1774. #ifndef NOSPL
  1775. { "function", XYFUNC, 0 },
  1776. #endif /* NOSPL */
  1777. #ifdef NEWFTP
  1778. { "get-put-remote", XYGPR, 0 },
  1779. #endif /* NEWFTP */
  1780. #ifdef KUI
  1781. { "gui", XYGUI, 0 },
  1782. #endif /* KUI */
  1783. { "handshake", XYHAND, 0 },
  1784. { "hints", XYHINTS, 0 },
  1785. #ifdef NETCONN
  1786. { "host", XYHOST, CM_LOC },
  1787. #endif /* NETCONN */
  1788. #ifndef NOSPL
  1789. { "i", XYINPU, CM_INV|CM_ABR },
  1790. #endif /* NOSPL */
  1791. #ifdef IKSD
  1792. { "iks", XYIKS, 0 },
  1793. #else
  1794. { "iks", XYIKS, CM_INV },
  1795. #endif /* IKSD */
  1796. #ifndef NOSPL
  1797. { "in", XYINPU, CM_INV|CM_ABR },
  1798. #endif /* NOSPL */
  1799. #ifndef NOXFER
  1800. { "incomplete", XYIFD, CM_INV },
  1801. #endif /* NOXFER */
  1802. #ifndef NOSPL
  1803. { "input", XYINPU, 0 },
  1804. #endif /* NOSPL */
  1805. #ifndef NOSETKEY
  1806. { "key", XYKEY, 0 },
  1807. #endif /* NOSETKEY */
  1808. { "l", XYLINE, CM_INV|CM_ABR },
  1809. #ifndef NOCSETS
  1810. { "language", XYLANG, 0 },
  1811. #endif /* NOCSETS */
  1812. #ifndef NOLOCAL
  1813. { "line", XYLINE, CM_LOC },
  1814. { "local-echo", XYLCLE, CM_INV|CM_LOC },
  1815. #endif /* NOLOCAL */
  1816. #ifdef HAVE_LOCALE
  1817. { "locale", XYLOCALE,0 },
  1818. #endif /* HAVE_LOCALE */
  1819. #ifdef LOCUS
  1820. { "locus", XYLOCUS, 0 },
  1821. #endif /* LOCUS */
  1822. #ifndef NOSPL
  1823. { "login", XYLOGIN, CM_LOC },
  1824. #endif /* NOSPL */
  1825. #ifndef NOSPL
  1826. { "macro", XYMACR, 0 },
  1827. #endif /* NOSPL */
  1828. { "match", XYMATCH, 0 },
  1829. #ifdef COMMENT
  1830. #ifdef VMS
  1831. { "messages", XYMSGS, 0 },
  1832. #endif /* VMS */
  1833. #endif /* COMMENT */
  1834. #ifndef NODIAL
  1835. { "modem", XYMODM, CM_LOC },
  1836. #endif /* NODIAL */
  1837. #ifndef NOLOCAL
  1838. #ifdef OS2MOUSE
  1839. { "mouse", XYMOUSE, 0 },
  1840. #endif /* OS2MOUSE */
  1841. #endif /* NOLOCAL */
  1842. #ifdef OS2
  1843. { "mskermit", XYMSK, 0 },
  1844. #endif /* OS2 */
  1845. #ifdef NETCONN
  1846. { "network", XYNET, CM_LOC },
  1847. #endif /* NETCONN */
  1848. #ifndef NOSPL
  1849. { "output", XYOUTP, 0 },
  1850. #endif /* NOSPL */
  1851. { "options", XYOPTS, 0 },
  1852. { "pause", XYSLEEP, CM_INV },
  1853. #ifdef ANYX25
  1854. #ifndef IBMX25
  1855. { "pad", XYPAD, CM_LOC },
  1856. #endif /* IBMX25 */
  1857. #endif /* ANYX25 */
  1858. { "parity", XYPARI, 0 },
  1859. #ifndef NOLOCAL
  1860. #ifdef OS2
  1861. { "port", XYLINE, CM_LOC },
  1862. #else
  1863. { "port", XYLINE, CM_INV|CM_LOC },
  1864. #endif /* OS2 */
  1865. #endif /* NOLOCAL */
  1866. #ifndef NOFRILLS
  1867. { "pr", XYPROM, CM_INV|CM_ABR },
  1868. { "printer", XYPRTR, 0 },
  1869. #endif /* NOFRILLS */
  1870. #ifdef OS2
  1871. { "priority", XYPRTY, 0 },
  1872. #endif /* OS2 */
  1873. #ifdef CK_SPEED
  1874. { "prefixing", XYPREFIX, 0 },
  1875. #endif /* CK_SPEED */
  1876. #ifndef NOFRILLS
  1877. { "prompt", XYPROM, 0 },
  1878. #endif /* NOFRILLS */
  1879. #ifndef NOXFER
  1880. { "protocol", XYPROTO, 0 },
  1881. #endif /* NOXFER */
  1882. { "q", XYQUIE, CM_INV|CM_ABR },
  1883. #ifndef NOXFER
  1884. { "q8flag", XYQ8FLG, CM_INV },
  1885. #endif /* NOXFER */
  1886. #ifdef QNX
  1887. { "qnx-port-lock", XYQNXPL, 0 },
  1888. #else
  1889. { "qnx-port-lock", XYQNXPL, CM_INV },
  1890. #endif /* QNX */
  1891. { "quiet", XYQUIE, 0 },
  1892. #ifndef NOXFER
  1893. { "rec", XYRECV, CM_INV|CM_ABR },
  1894. { "receive", XYRECV, 0 },
  1895. { "recv", XYRECV, CM_INV },
  1896. #endif /* NOXFER */
  1897. { "reliable", XYRELY, 0 },
  1898. { "rename", XY_REN, 0 },
  1899. #ifndef NOXFER
  1900. { "repeat", XYREPT, 0 },
  1901. { "retry-limit", XYRETR, 0 },
  1902. #endif /* NOXFER */
  1903. #ifdef CKROOT
  1904. { "root", XYROOT, 0 },
  1905. #endif /* CKROOT */
  1906. #ifndef NOSCRIPT
  1907. { "script", XYSCRI, CM_LOC },
  1908. #endif /* NOSCRIPT */
  1909. #ifndef NOXFER
  1910. { "send", XYSEND, 0 },
  1911. #ifndef NOLOCAL
  1912. #ifndef NOSERVER
  1913. { "ser", XYSERV, CM_INV|CM_ABR },
  1914. #endif /* NOSERVER */
  1915. #endif /* NOXFER */
  1916. { "serial", XYSERIAL,CM_LOC },
  1917. #endif /* NOLOCAL */
  1918. #ifndef NOSERVER
  1919. { "server", XYSERV, 0 },
  1920. #endif /* NOSERVER */
  1921. #ifdef SESLIMIT
  1922. #ifndef NOLOCAL
  1923. { "session-l", XYSESS, CM_INV|CM_ABR },
  1924. #endif /* NOLOCAL */
  1925. { "session-limit", XYLIMIT, CM_INV|CM_LOC }, /* Session Limit */
  1926. #endif /* SESLIMIT */
  1927. #ifndef NOLOCAL
  1928. { "session-log", XYSESS, CM_LOC },
  1929. #endif /* NOLOCAL */
  1930. #ifndef NOSPL
  1931. #ifndef NOSEXP
  1932. { "sexpression", XYSEXP, CM_INV },
  1933. #endif /* NOSEXP */
  1934. #endif /* NOSPL */
  1935. { "sleep", XYSLEEP, 0 },
  1936. #ifndef NOLOCAL
  1937. { "speed", XYSPEE, CM_LOC },
  1938. #endif /* NOLOCAL */
  1939. #ifdef ANYSSH
  1940. { "ssh", XYSSH, 0 },
  1941. #endif /* ANYSSH */
  1942. #ifndef NOSPL
  1943. { "startup-file", XYSTARTUP, CM_INV },
  1944. #endif /* NOSPL */
  1945. #ifndef NOLOCAL
  1946. #ifdef HWPARITY
  1947. { "stop-bits", XYSTOP, CM_LOC },
  1948. #else
  1949. #ifdef TN_COMPORT
  1950. { "stop-bits", XYSTOP, CM_LOC },
  1951. #endif /* TN_COMPORT */
  1952. #endif /* HWPARITY */
  1953. #endif /* NOLOCAL */
  1954. #ifndef NOXFER
  1955. #ifdef STREAMING
  1956. { "streaming", XYSTREAM, 0 },
  1957. #endif /* STREAMING */
  1958. #endif /* NOXFER */
  1959. #ifndef NOJC
  1960. { "suspend", XYSUSP, CM_PSH },
  1961. #endif /* NOJC */
  1962. #ifdef CKSYSLOG
  1963. { "syslog", XYSYSL, CM_INV },
  1964. #endif /* CKSYSLOG */
  1965. { "take", XYTAKE, 0 },
  1966. #ifdef CK_TAPI
  1967. { "tapi", XYTAPI, CM_LOC },
  1968. #endif /* CK_TAPI */
  1969. #ifndef NOTCPOPTS
  1970. #ifdef TCPSOCKET
  1971. { "tcp", XYTCP, CM_LOC },
  1972. #endif /* TCPSOCKET */
  1973. #endif /* NOTCPOPTS */
  1974. #ifdef TNCODE
  1975. { "tel", XYTEL, CM_INV|CM_ABR },
  1976. { "telnet", XYTEL, 0 },
  1977. { "telopt", XYTELOP, 0 },
  1978. #endif /* TNCODE */
  1979. #ifndef NOSPL
  1980. { "temp-directory", XYTMPDIR,0 },
  1981. #endif /* NOSPL */
  1982. #ifndef NOLOCAL
  1983. { "terminal", XYTERM, CM_LOC },
  1984. #endif /* NOLOCAL */
  1985. #ifdef OS2
  1986. { "title", XYTITLE, CM_LOC },
  1987. #endif /* OS2 */
  1988. #ifndef NOSPL
  1989. { "tmp-directory", XYTMPDIR,CM_INV },
  1990. #endif /* NOSPL */
  1991. #ifdef TLOG
  1992. { "transaction-log", XYTLOG, 0 },
  1993. #endif /* TLOG */
  1994. #ifndef NOXFER
  1995. { "transfer", XYXFER, 0 },
  1996. #endif /* NOXFER */
  1997. #ifndef NOXMIT
  1998. { "transmit", XYXMIT, 0 },
  1999. #endif /* NOXMIT */
  2000. #ifndef NOXFER
  2001. #ifndef NOCSETS
  2002. { "unknown-char-set", XYUNCS, 0 },
  2003. #endif /* NOCSETS */
  2004. #ifndef NOSPL
  2005. { "variable-evaluation", XYVAREV, CM_INV },
  2006. #endif /* NOSPL */
  2007. #endif /* NOXFER */
  2008. { "wait", XYSLEEP, CM_INV },
  2009. #ifndef NOPUSH
  2010. #ifdef UNIX
  2011. { "wildcard-expansion", XYWILD, 0 },
  2012. #endif /* UNIX */
  2013. #endif /* NOPUSH */
  2014. #ifdef NT
  2015. { "w", XYWIND, CM_INV|CM_ABR },
  2016. { "wi", XYWIND, CM_INV|CM_ABR },
  2017. { "win", XYWIND, CM_INV|CM_ABR },
  2018. #endif /* NT */
  2019. { "window-size", XYWIND, 0 },
  2020. #ifdef NT
  2021. { "win95", XYWIN95, 0 },
  2022. #endif /* NT */
  2023. #ifdef ANYX25
  2024. { "x.25", XYX25, CM_LOC },
  2025. { "x25", XYX25, CM_INV|CM_LOC },
  2026. #endif /* ANYX25 */
  2027. { "xfer", XYXFER, CM_INV },
  2028. #ifndef NOXMIT
  2029. { "xmit", XYXMIT, CM_INV },
  2030. #endif /* NOXMIT */
  2031. { "", 0, 0 }
  2032. };
  2033. int nprm = (sizeof(prmtab) / sizeof(struct keytab)) - 1; /* How many */
  2034. struct keytab scntab[] = { /* Screen commands */
  2035. { "clear", SCN_CLR, 0 },
  2036. { "cleol", SCN_CLE, 0 },
  2037. { "move-to", SCN_MOV, 0 }
  2038. };
  2039. int nscntab = (sizeof(scntab) / sizeof(struct keytab)); /* How many */
  2040. #ifdef ANYSSH /* SSH command table */
  2041. #ifdef SSHBUILTIN
  2042. int ssh_pf_lcl_n = 0,
  2043. ssh_pf_rmt_n = 0;
  2044. struct ssh_pf ssh_pf_lcl[32] = { 0, NULL, 0 }; /* SSH Port Forwarding */
  2045. struct ssh_pf ssh_pf_rmt[32] = { 0, NULL, 0 }; /* structs... */
  2046. extern char * ssh_hst, * ssh_cmd, * ssh_prt;
  2047. extern int ssh_ver, ssh_xfw;
  2048. char * ssh_tmpuid = NULL, *ssh_tmpcmd = NULL, *ssh_tmpport = NULL,
  2049. * ssh_tmpstr = NULL;
  2050. int
  2051. sshk_type = SSHKT_2D, /* SSH KEY CREATE /TYPE:x */
  2052. sshk_bits = 1024, /* SSH KEY CREATE /BITS:n */
  2053. sshk_din = SKDF_OSSH, /* SSH KEY DISPLAY /IN-FORMAT: */
  2054. sshk_dout = SKDF_OSSH; /* SSH KEY DISPLAY /OUT-FORMAT: */
  2055. char
  2056. * sshk1_comment = NULL, /* SSH V1 COMMENT */
  2057. * sshkp_old = NULL, /* Old key passphrase */
  2058. * sshkp_new = NULL, /* New key passphrase */
  2059. * sshkc_pass = NULL, /* KEY CREATE /PASS:xxx */
  2060. * sshkc_comm = NULL, /* KEY CREATE /V1-RSA-COMMENT:xxx */
  2061. * sshd_file = NULL, /* DISPLAY file */
  2062. * sshk_file = NULL; /* SSH CREATE KEY file */
  2063. static struct keytab sshclr[] = {
  2064. { "local-port-forward", SSHC_LPF, 0 },
  2065. { "remote-port-forward", SSHC_RPF, 0 },
  2066. { "", 0, 0 }
  2067. };
  2068. static int nsshclr = (sizeof(sshclr) / sizeof(struct keytab)) - 1;
  2069. struct keytab sshopnsw[] = {
  2070. { "/command", SSHSW_CMD, CM_ARG },
  2071. { "/password", SSHSW_PWD, CM_ARG },
  2072. { "/subsystem", SSHSW_SUB, CM_ARG },
  2073. { "/user", SSHSW_USR, CM_ARG },
  2074. { "/version", SSHSW_VER, CM_ARG },
  2075. { "/x11-forwarding", SSHSW_X11, CM_ARG },
  2076. { "", 0, 0 }
  2077. };
  2078. int nsshopnsw = (sizeof(sshopnsw) / sizeof(struct keytab)) - 1;
  2079. static struct keytab sshkwtab[] = {
  2080. { "add", XSSH_ADD, 0 },
  2081. { "agent", XSSH_AGT, 0 },
  2082. { "clear", XSSH_CLR, 0 },
  2083. { "forward-local-port", XSSH_FLP, CM_INV },
  2084. { "forward-remote-port", XSSH_FRP, CM_INV },
  2085. { "key", XSSH_KEY, 0 },
  2086. { "open", XSSH_OPN, 0 },
  2087. { "v2", XSSH_V2, 0 },
  2088. { "", 0, 0 }
  2089. };
  2090. static int nsshcmd = (sizeof(sshkwtab) / sizeof(struct keytab)) - 1;
  2091. static struct keytab ssh2tab[] = {
  2092. { "rekey", XSSH2_RKE, 0 },
  2093. { "", 0, 0 }
  2094. };
  2095. static int nssh2tab = (sizeof(ssh2tab) / sizeof(struct keytab));
  2096. static struct keytab addfwd[] = { /* SET SSH ADD command table */
  2097. { "local-port-forward", SSHF_LCL, 0 },
  2098. { "remote-port-forward", SSHF_RMT, 0 },
  2099. { "", 0, 0 }
  2100. };
  2101. static int naddfwd = (sizeof(addfwd) / sizeof(struct keytab)) - 1;
  2102. static struct keytab sshagent[] = { /* SET SSH AGENT command table */
  2103. { "add", SSHA_ADD, 0 },
  2104. { "delete", SSHA_DEL, 0 },
  2105. { "list", SSHA_LST, 0 },
  2106. { "", 0, 0 }
  2107. };
  2108. static int nsshagent = (sizeof(sshagent) / sizeof(struct keytab)) - 1;
  2109. static struct keytab sshagtsw[] = { /* SET SSH AGENT LIST switch table */
  2110. { "/fingerprint", SSHASW_FP, 0 },
  2111. { "", 0, 0 }
  2112. };
  2113. static int nsshagtsw = (sizeof(sshagtsw) / sizeof(struct keytab)) - 1;
  2114. static struct keytab sshkey[] = { /* SET SSH KEY command table */
  2115. { "change-passphrase", SSHK_PASS, 0 },
  2116. { "create", SSHK_CREA, 0 },
  2117. { "display", SSHK_DISP, 0 },
  2118. { "v1", SSHK_V1, 0 },
  2119. { "", 0, 0 }
  2120. };
  2121. static int nsshkey = (sizeof(sshkey) / sizeof(struct keytab)) - 1;
  2122. static struct keytab sshkv1[] = { /* SET SSH KEY V1 command table */
  2123. { "set-comment", 1, 0 }
  2124. };
  2125. static struct keytab sshkpsw[] = { /* SET SSH KEY PASSPHRASE table */
  2126. { "/new-passphrase", 2, CM_ARG },
  2127. { "/old-passphrase", 1, CM_ARG }
  2128. };
  2129. static struct keytab sshkcrea[] = { /* SSH KEY CREATE table */
  2130. { "/bits", SSHKC_BI, CM_ARG },
  2131. { "/passphrase", SSHKC_PP, CM_ARG },
  2132. { "/type", SSHKC_TY, CM_ARG },
  2133. { "/v1-rsa-comment", SSHKC_1R, CM_ARG }
  2134. };
  2135. static int nsshkcrea = (sizeof(sshkcrea) / sizeof(struct keytab));
  2136. static struct keytab sshkcty[] = { /* SSH KEY CREATE /TYPE:xxx */
  2137. { "srp", SSHKT_SRP, 0 },
  2138. { "v1-rsa", SSHKT_1R, 0 },
  2139. { "v2-dsa", SSHKT_2D, 0 },
  2140. { "v2-rsa", SSHKT_2R, 0 }
  2141. };
  2142. static int nsshkcty = (sizeof(sshkcty) / sizeof(struct keytab));
  2143. static struct keytab sshdswi[] = { /* SET SSH KEY DISPLAY /switches */
  2144. { "/format", SSHKD_OUT, CM_ARG }
  2145. };
  2146. static int nsshdswi = (sizeof(sshdswi) / sizeof(struct keytab));
  2147. #ifdef COMMENT
  2148. static struct keytab sshdifmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */
  2149. { "openssh", SKDF_OSSH, 0 },
  2150. { "ssh.com", SKDF_SSHC, 0 }
  2151. };
  2152. static int nsshdifmt = (sizeof(sshdifmt) / sizeof(struct keytab));
  2153. #endif /* COMMENT */
  2154. static struct keytab sshdofmt[] = { /* SSH KEY DISPLAY /IN-FORMAT: */
  2155. { "fingerprint", SKDF_FING, 0 },
  2156. { "ietf", SKDF_IETF, 0 },
  2157. { "openssh", SKDF_OSSH, 0 },
  2158. { "ssh.com", SKDF_SSHC, 0 }
  2159. };
  2160. static int nsshdofmt = (sizeof(sshdofmt) / sizeof(struct keytab));
  2161. static struct keytab sshkermit[] = { /* SKERMIT */
  2162. { "open", SKRM_OPN, 0 }
  2163. };
  2164. static int nsshkermit = (sizeof(sshkermit) / sizeof(struct keytab));
  2165. struct keytab sshkrmopnsw[] = {
  2166. { "/password", SSHSW_PWD, CM_ARG },
  2167. { "/user", SSHSW_USR, CM_ARG },
  2168. { "/version", SSHSW_VER, CM_ARG },
  2169. { "", 0, 0 }
  2170. };
  2171. int nsshkrmopnsw = (sizeof(sshkrmopnsw) / sizeof(struct keytab)) - 1;
  2172. #endif /* SSHBUILTIN */
  2173. #ifdef SFTP_BUILTIN
  2174. static struct keytab sftpkwtab[] = { /* SFTP */
  2175. { "cd", SFTP_CD, 0 },
  2176. { "chgrp", SFTP_CHGRP, 0 },
  2177. { "chmod", SFTP_CHMOD, 0 },
  2178. { "chown", SFTP_CHOWN, 0 },
  2179. { "delete", SFTP_RM, 0 },
  2180. { "dir", SFTP_DIR, 0 },
  2181. { "get", SFTP_GET, 0 },
  2182. { "mkdir", SFTP_MKDIR, 0 },
  2183. { "open", SFTP_OPN, 0 },
  2184. { "put", SFTP_PUT, 0 },
  2185. { "pwd", SFTP_PWD, 0 },
  2186. { "rename", SFTP_REN, 0 },
  2187. { "rm", SFTP_RM, CM_INV },
  2188. { "rmdir", SFTP_RMDIR, 0 },
  2189. { "symlink", SFTP_LINK, 0 },
  2190. { "version", SFTP_VER, 0 }
  2191. };
  2192. static int nsftpkwtab = (sizeof(sftpkwtab) / sizeof(struct keytab));
  2193. #endif /* SFTP_BUILTIN */
  2194. #endif /* ANYSSH */
  2195. #ifdef NETCONN
  2196. struct keytab netkey[] = { /* SET NETWORK table */
  2197. { "directory", XYNET_D, 0 },
  2198. { "type", XYNET_T, 0 }
  2199. };
  2200. int nnetkey = (sizeof(netkey) / sizeof(struct keytab));
  2201. struct keytab netcmd[] = {
  2202. /*
  2203. These are the network types.
  2204. */
  2205. #ifdef NETCMD
  2206. { "command", NET_CMD, CM_INV }, /* Command */
  2207. #endif /* NETCMD */
  2208. #ifdef DECNET /* DECnet / PATHWORKS */
  2209. { "decnet", NET_DEC, 0 },
  2210. #endif /* DECNET */
  2211. #ifdef NETDLL
  2212. { "dll", NET_DLL, CM_INV }, /* DLL to be loaded */
  2213. #endif /* NETDLL */
  2214. #ifdef NETFILE
  2215. { "file", NET_FILE, CM_INV }, /* FILE (real crude) */
  2216. #endif /* NETFILE */
  2217. #ifdef NPIPE /* Named Pipes */
  2218. { "named-pipe", NET_PIPE, 0 },
  2219. #endif /* NPIPE */
  2220. #ifdef CK_NETBIOS
  2221. { "netbios", NET_BIOS, 0 }, /* NETBIOS */
  2222. #endif /* CK_NETBIOS */
  2223. #ifdef DECNET /* DECnet / PATHWORKS (alias) */
  2224. { "pathworks", NET_DEC, CM_INV },
  2225. #endif /* DECNET */
  2226. #ifdef NETCMD
  2227. { "pipe", NET_CMD, 0 }, /* Pipe */
  2228. #endif /* NETCMD */
  2229. #ifdef NETPTY
  2230. { "pseudoterminal",NET_PTY, 0 }, /* Pseudoterminal */
  2231. #endif /* NETPTY */
  2232. #ifdef NETPTY
  2233. { "pty", NET_PTY, CM_INV }, /* Inv syn for pseudoterm */
  2234. #endif /* NETPTY */
  2235. #ifdef SSHBUILTIN
  2236. { "ssh", NET_SSH, 0 },
  2237. #endif /* SSHBUILTIN */
  2238. #ifdef SUPERLAT
  2239. { "superlat", NET_SLAT, 0 }, /* Meridian Technologies' SuperLAT */
  2240. #endif /* SUPERLAT */
  2241. #ifdef TCPSOCKET /* TCP/IP sockets library */
  2242. { "tcp/ip", NET_TCPB, 0 },
  2243. #endif /* TCPSOCKET */
  2244. #ifdef SUPERLAT
  2245. { "tes32", NET_SLAT, 0 }, /* Emulux TES32 */
  2246. #endif /* SUPERLAT */
  2247. #ifdef ANYX25 /* X.25 */
  2248. #ifdef SUNX25
  2249. { "x", NET_SX25, CM_INV|CM_ABR },
  2250. { "x.25", NET_SX25, 0 },
  2251. { "x25", NET_SX25, CM_INV },
  2252. #else
  2253. #ifdef STRATUSX25
  2254. { "x", NET_VX25, CM_INV|CM_ABR },
  2255. { "x.25", NET_VX25, 0 },
  2256. { "x25", NET_VX25, CM_INV },
  2257. #endif /* STRATUSX25 */
  2258. #endif /* SUNX25 */
  2259. #ifdef IBMX25
  2260. { "x", NET_IX25, CM_INV|CM_ABR },
  2261. { "x.25", NET_IX25, CM_INV },
  2262. { "x25", NET_IX25, CM_INV },
  2263. #endif /* IBMX25 */
  2264. #ifdef HPX25
  2265. { "x", NET_IX25, CM_INV|CM_ABR },
  2266. { "x.25", NET_IX25, 0 },
  2267. { "x25", NET_IX25, CM_INV },
  2268. #endif /* HPX25 */
  2269. #endif /* ANYX25 */
  2270. { "", 0, 0 }
  2271. };
  2272. int nnets = (sizeof(netcmd) / sizeof(struct keytab));
  2273. #ifndef NOTCPOPTS
  2274. #ifdef TCPSOCKET
  2275. /* TCP options */
  2276. struct keytab tcpopt[] = {
  2277. { "address", XYTCP_ADDRESS, 0 },
  2278. #ifdef CK_DNS_SRV
  2279. { "dns-service-records", XYTCP_DNS_SRV, 0 },
  2280. #endif /* CK_DNS_SRV */
  2281. #ifdef SO_DONTROUTE
  2282. { "dontroute", XYTCP_DONTROUTE, 0 },
  2283. #endif /* SO_DONTROUTE */
  2284. #ifndef NOHTTP
  2285. { "http-proxy", XYTCP_HTTP_PROXY, 0 },
  2286. #endif /* NOHTTP */
  2287. #ifdef SO_KEEPALIVE
  2288. { "keepalive", XYTCP_KEEPALIVE, 0 },
  2289. #endif /* SO_KEEPALIVE */
  2290. #ifdef SO_LINGER
  2291. { "linger", XYTCP_LINGER, 0 },
  2292. #endif /* SO_LINGER */
  2293. #ifdef TCP_NODELAY
  2294. { "nagle", XYTCP_NAGLE, CM_INV },
  2295. { "nodelay", XYTCP_NODELAY, 0 },
  2296. #endif /* TCP_NODELAY */
  2297. { "reverse-dns-lookup", XYTCP_RDNS, 0 },
  2298. #ifdef SO_RCVBUF
  2299. { "recvbuf", XYTCP_RECVBUF, 0 },
  2300. #endif /* SO_RCVBUF */
  2301. #ifdef SO_SNDBUF
  2302. { "sendbuf", XYTCP_SENDBUF, 0 },
  2303. #endif /* SO_SNDBUF */
  2304. #ifdef NT
  2305. #ifdef CK_SOCKS
  2306. { "socks-server", XYTCP_SOCKS_SVR, 0 },
  2307. #endif /* CK_SOCKS */
  2308. #endif /* NT */
  2309. #ifdef VMS
  2310. #ifdef DEC_TCPIP
  2311. { "ucx-port-bug", XYTCP_UCX, 0 },
  2312. #endif /* DEC_TCPIP */
  2313. #endif /* VMS */
  2314. { "",0,0 }
  2315. };
  2316. int ntcpopt = (sizeof(tcpopt) / sizeof(struct keytab));
  2317. #endif /* TCPSOCKET */
  2318. #endif /* NOTCPOPTS */
  2319. #endif /* NETCONN */
  2320. #ifdef OS2
  2321. /* K95 Manual Chapter Table -- Keep these two tables in sync! */
  2322. static char * linktbl[] = { /* Internal links in k95.htm */
  2323. "#top", /* 00 */
  2324. "#what", /* 01 */
  2325. "#install", /* 02 */
  2326. "#start", /* 03 */
  2327. "#dialer", /* 04 */
  2328. "#entries", /* 05 */
  2329. "#command", /* 06 */
  2330. "#terminal", /* 07 */
  2331. "#transfer", /* 08 */
  2332. "#hostmode" /* 09 */
  2333. };
  2334. static struct keytab chaptbl[] = {
  2335. { "Command-Screen", 6, 0 },
  2336. { "Contents", 0, 0 },
  2337. { "Dialer-Entries", 5, 0 },
  2338. { "File-Transfer", 8, 0 },
  2339. { "Getting-Started", 3, 0 },
  2340. { "Host-Mode", 9, 0 },
  2341. { "Installation", 2, 0 },
  2342. { "Terminal-Emulation", 7, 0 },
  2343. { "Using-The-Dialer", 4, 0 },
  2344. { "What-Is-K95", 1, 0 },
  2345. { "", 0, 0 }
  2346. };
  2347. static int nchaptbl = (sizeof(chaptbl) / sizeof(struct keytab) - 1);
  2348. #endif /* OS2 */
  2349. #ifndef NOXFER
  2350. /* Remote Command Table */
  2351. struct keytab remcmd[] = {
  2352. #ifndef NOSPL
  2353. { "as", XZASG, CM_INV|CM_ABR },
  2354. { "asg", XZASG, CM_INV },
  2355. { "assign", XZASG, 0 },
  2356. #endif /* NOSPL */
  2357. { "cd", XZCWD, 0 },
  2358. { "cdup", XZCDU, CM_INV },
  2359. { "copy", XZCPY, 0 },
  2360. { "cwd", XZCWD, CM_INV },
  2361. { "delete", XZDEL, 0 },
  2362. { "directory", XZDIR, 0 },
  2363. { "e", XZXIT, CM_ABR|CM_INV },
  2364. { "erase", XZDEL, CM_INV },
  2365. { "exit", XZXIT, 0 },
  2366. { "help", XZHLP, 0 },
  2367. #ifndef NOPUSH
  2368. { "host", XZHOS, 0 },
  2369. #endif /* NOPUSH */
  2370. #ifndef NOFRILLS
  2371. { "kermit", XZKER, 0 },
  2372. { "l", XZLGI, CM_ABR|CM_INV },
  2373. { "lo", XZLGI, CM_ABR|CM_INV },
  2374. { "log", XZLGI, CM_ABR|CM_INV },
  2375. { "login", XZLGI, 0 },
  2376. { "logout", XZLGO, 0 },
  2377. { "message", XZMSG, 0 },
  2378. { "mkdir", XZMKD, 0 },
  2379. { "print", XZPRI, 0 },
  2380. #endif /* NOFRILLS */
  2381. { "pwd", XZPWD, 0 },
  2382. #ifndef NOSPL
  2383. { "query", XZQUE, 0 },
  2384. #endif /* NOSPL */
  2385. { "rename", XZREN, 0 },
  2386. { "rmdir", XZRMD, 0 },
  2387. { "set", XZSET, 0 },
  2388. { "space", XZSPA, 0 },
  2389. #ifndef NOFRILLS
  2390. { "type", XZTYP, 0 },
  2391. { "who", XZWHO, 0 },
  2392. #endif /* NOFRILLS */
  2393. { "", 0, 0}
  2394. };
  2395. int nrmt = (sizeof(remcmd) / sizeof(struct keytab)) - 1;
  2396. #endif /* NOXFER */
  2397. struct keytab logtab[] = {
  2398. #ifdef CKLOGDIAL
  2399. { "connections", LOGM, CM_INV },
  2400. { "cx", LOGM, 0 },
  2401. #endif /* CKLOGDIAL */
  2402. #ifdef DEBUG
  2403. { "debugging", LOGD, 0 },
  2404. #endif /* DEBUG */
  2405. { "packets", LOGP, 0 },
  2406. #ifndef NOLOCAL
  2407. { "session", LOGS, 0 },
  2408. #endif /* NOLOCAL */
  2409. #ifdef TLOG
  2410. { "transactions", LOGT, 0 },
  2411. #endif /* TLOG */
  2412. { "", 0, 0 }
  2413. };
  2414. int nlog = (sizeof(logtab) / sizeof(struct keytab)) - 1;
  2415. struct keytab writab[] = {
  2416. #ifndef NOSPL
  2417. { "append-file", LOGW, CM_INV },
  2418. #endif /* NOSPL */
  2419. { "debug-log", LOGD, 0 },
  2420. { "error", LOGE, 0 },
  2421. #ifndef NOSPL
  2422. { "file", LOGW, 0 },
  2423. #endif /* NOSPL */
  2424. { "packet-log", LOGP, 0 },
  2425. { "screen", LOGX, 0 },
  2426. #ifndef NOLOCAL
  2427. { "session-log", LOGS, 0 },
  2428. #endif /* NOLOCAL */
  2429. { "sys$output", LOGX, CM_INV },
  2430. { "t", LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2431. { "tr", LOGT, CM_ABR|CM_INV }, /* the book... */
  2432. { "tra", LOGT, CM_ABR|CM_INV },
  2433. { "tran", LOGT, CM_ABR|CM_INV },
  2434. { "trans", LOGT, CM_ABR|CM_INV },
  2435. { "transa", LOGT, CM_ABR|CM_INV },
  2436. { "transac", LOGT, CM_ABR|CM_INV },
  2437. { "transact", LOGT, CM_ABR|CM_INV },
  2438. { "transacti", LOGT, CM_ABR|CM_INV },
  2439. { "transactio", LOGT, CM_ABR|CM_INV },
  2440. { "transaction", LOGT, CM_ABR|CM_INV },
  2441. { "transaction-log", LOGT, 0 },
  2442. { "transactions", LOGT, CM_INV }
  2443. };
  2444. int nwri = (sizeof(writab) / sizeof(struct keytab));
  2445. static struct keytab clrtab[] = { /* Keywords for CLEAR command */
  2446. #ifndef NOSPL
  2447. { "alarm", CLR_ALR, 0 },
  2448. #ifdef CK_APC
  2449. { "apc", CLR_APC, 0 },
  2450. #endif /* CK_APC */
  2451. #ifdef PATTERNS
  2452. { "binary-patterns", CLR_BIN, 0 },
  2453. #endif /* PATTERNS */
  2454. { "both", CLR_DEV|CLR_INP, CM_INV },
  2455. #endif /* NOSPL */
  2456. #ifdef OS2
  2457. { "command-screen", CLR_CMD, 0 },
  2458. #endif /* OS2 */
  2459. #ifndef NOSPL
  2460. { "device", CLR_DEV, CM_INV|CM_ABR },
  2461. { "device-and-input", CLR_DEV|CLR_INP, 0 },
  2462. #endif /* NOSPL */
  2463. { "device-buffer", CLR_DEV, 0 },
  2464. #ifndef NODIAL
  2465. { "dial-status", CLR_DIA, 0 },
  2466. #endif /* NODIAL */
  2467. #ifndef NOSPL
  2468. { "input-buffer", CLR_INP, 0 },
  2469. #endif /* NOSPL */
  2470. { "keyboard-buffer", CLR_KBD, 0 },
  2471. { "send-list", CLR_SFL, 0 },
  2472. #ifdef OS2
  2473. { "scr", CLR_SCL, CM_INV|CM_ABR },
  2474. #endif /* OS2 */
  2475. { "screen", CLR_SCR, 0 },
  2476. #ifdef OS2
  2477. { "scrollback", CLR_SCL, CM_INV },
  2478. { "terminal-screen", CLR_TRM, 0 },
  2479. #endif /* OS2 */
  2480. #ifdef PATTERNS
  2481. { "text-patterns", CLR_TXT, 0 },
  2482. #endif /* PATTERNS */
  2483. { "", 0, 0 }
  2484. };
  2485. int nclear = (sizeof(clrtab) / sizeof(struct keytab)) - 1;
  2486. struct keytab clstab[] = { /* Keywords for CLOSE command */
  2487. #ifndef NOSPL
  2488. { "!read", LOGR, CM_INV },
  2489. { "!write", LOGW, CM_INV },
  2490. #ifndef NOPUSH
  2491. #endif /* NOPUSH */
  2492. #endif /* NOSPL */
  2493. #ifndef NOSPL
  2494. { "append-file", LOGW, CM_INV },
  2495. #endif /* NOSPL */
  2496. #ifndef NOLOCAL
  2497. { "connection", 9999, 0 },
  2498. #endif /* NOLOCAL */
  2499. #ifdef CKLOGDIAL
  2500. { "cx-log", LOGM, 0 },
  2501. #endif /* CKLOGDIAL */
  2502. #ifdef DEBUG
  2503. { "debug-log", LOGD, 0 },
  2504. #endif /* DEBUG */
  2505. { "host", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2506. { "line", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2507. { "p", LOGP, CM_INV|CM_ABR },
  2508. { "packet-log", LOGP, 0 },
  2509. { "port", 9999, CM_INV }, /* Synonym for CLOSE CONNECTION */
  2510. #ifndef NOSPL
  2511. { "read-file", LOGR, 0 },
  2512. #endif /* NOSPL */
  2513. #ifndef NOLOCAL
  2514. { "session-log", LOGS, 0 },
  2515. #endif /* NOLOCAL */
  2516. #ifdef TLOG
  2517. { "t", LOGT, CM_ABR|CM_INV }, /* Because of a typo in */
  2518. { "tr", LOGT, CM_ABR|CM_INV }, /* the book... */
  2519. { "tra", LOGT, CM_ABR|CM_INV },
  2520. { "tran", LOGT, CM_ABR|CM_INV },
  2521. { "trans", LOGT, CM_ABR|CM_INV },
  2522. { "transa", LOGT, CM_ABR|CM_INV },
  2523. { "transac", LOGT, CM_ABR|CM_INV },
  2524. { "transact", LOGT, CM_ABR|CM_INV },
  2525. { "transacti", LOGT, CM_ABR|CM_INV },
  2526. { "transactio", LOGT, CM_ABR|CM_INV },
  2527. { "transaction", LOGT, CM_ABR|CM_INV },
  2528. { "transaction-log", LOGT, 0 },
  2529. { "transactions", LOGT, CM_INV },
  2530. #endif /* TLOG */
  2531. #ifndef NOSPL
  2532. { "write-file", LOGW, 0 },
  2533. #endif /* NOSPL */
  2534. { "", 0, 0 }
  2535. };
  2536. int ncls = (sizeof(clstab) / sizeof(struct keytab)) - 1;
  2537. /* SHOW command arguments */
  2538. #ifndef NOSHOW
  2539. struct keytab shotab[] = {
  2540. #ifndef NOSPL
  2541. { "alarm", SHALRM, 0 },
  2542. { "arg", SHARG, CM_INV|CM_ABR },
  2543. { "arguments", SHARG, 0 },
  2544. { "args", SHARG, CM_INV },
  2545. { "arrays", SHARR, 0 },
  2546. #endif /* NOSPL */
  2547. #ifndef NOCSETS
  2548. { "associations", SHASSOC, 0 },
  2549. #endif /* NOCSETS */
  2550. #ifndef NOXFER
  2551. { "attributes", SHATT, 0 },
  2552. #endif /* NOXFER */
  2553. #ifdef CK_AUTHENTICATION
  2554. { "authentication", SHOAUTH, CM_INV },
  2555. #endif /* CK_AUTHENTICATION */
  2556. #ifndef NOPUSH
  2557. #ifdef BROWSER
  2558. { "browser", SHBROWSE, CM_PSH|CM_LOC },
  2559. #endif /* BROWSER */
  2560. #endif /* NOPUSH */
  2561. { "cd", SHCD, 0 },
  2562. { "character-sets", SHCSE, 0 },
  2563. { "cmd", SHCMD, CM_INV },
  2564. #ifndef NOLOCAL
  2565. { "com", SHCOM, CM_INV|CM_ABR },
  2566. { "comm", SHCOM, CM_INV|CM_ABR },
  2567. { "communications", SHCOM, 0 },
  2568. #endif /* NOLOCAL */
  2569. { "command", SHCMD, 0 },
  2570. { "connection", SHCONNX, 0 },
  2571. #ifdef CK_SPEED
  2572. { "control-prefixing", SHCTL, 0 },
  2573. #endif /* CK_SPEED */
  2574. #ifdef CKLOGDIAL
  2575. { "cx", SHCONNX, CM_INV },
  2576. #endif /* CKLOGDIAL */
  2577. #ifndef NOSPL
  2578. { "count", SHCOU, 0 },
  2579. #endif /* NOSPL */
  2580. { "d", SHDIA, CM_INV|CM_ABR },
  2581. #ifdef VMS
  2582. { "default", SHDFLT, 0 },
  2583. #else
  2584. { "default", SHDFLT, CM_INV },
  2585. #endif /* VMS */
  2586. #ifndef NODIAL
  2587. { "dial", SHDIA, CM_LOC },
  2588. #endif /* NODIAL */
  2589. { "double/ignore",SHDBL, 0 },
  2590. #ifndef NOPUSH
  2591. #ifndef NOFRILLS
  2592. { "editor", SHEDIT, CM_PSH },
  2593. #endif /* NOFRILLS */
  2594. #endif /* NOPUSH */
  2595. #ifndef NOLOCAL
  2596. { "escape", SHESC, CM_LOC },
  2597. #endif /* NOLOCAL */
  2598. { "exit", SHEXI, 0 },
  2599. { "extended-options", SHXOPT, CM_INV },
  2600. { "features", SHFEA, 0 },
  2601. { "file", SHFIL, 0 },
  2602. #ifndef NOLOCAL
  2603. { "flow-control", SHOFLO, 0 },
  2604. #endif /* NOLOCAL */
  2605. #ifdef BROWSER
  2606. { "ftp", SHOFTP, CM_PSH|CM_LOC },
  2607. #else
  2608. #ifndef NOFTP
  2609. #ifndef SYSFTP
  2610. #ifdef TCPSOCKET
  2611. { "ftp", SHOFTP, 0 }, /* (built-in ftp) */
  2612. #endif /* TCPSOCKET */
  2613. #endif /* SYSFTP */
  2614. #endif /* NOFTP */
  2615. #endif /* BROWSER */
  2616. #ifndef NOSPL
  2617. { "functions", SHFUN, 0 },
  2618. { "globals", SHVAR, 0 },
  2619. #endif /* NOSPL */
  2620. #ifdef KUI
  2621. { "gui", SHOGUI, 0 },
  2622. #endif /* KUI */
  2623. #ifdef CK_RECALL
  2624. { "history", SHHISTORY, 0 },
  2625. #endif /* CK_RECALL */
  2626. { "ignore/double",SHDBL, CM_INV },
  2627. { "iksd", SHOIKS, CM_INV },
  2628. #ifndef NOSPL
  2629. { "input", SHINP, 0 },
  2630. #endif /* NOSPL */
  2631. #ifndef NOSETKEY
  2632. { "k", SHKEY, CM_INV|CM_ABR },
  2633. { "key", SHKEY, 0 },
  2634. #ifndef NOKVERBS
  2635. { "kverbs", SHKVB, 0 },
  2636. #endif /* NOKVERBS */
  2637. #endif /* NOSETKEY */
  2638. #ifdef CK_LABELED
  2639. { "labeled-file-info", SHLBL, 0 },
  2640. #endif /* CK_LABELED */
  2641. #ifndef NOCSETS
  2642. { "languages", SHLNG, 0 },
  2643. #ifndef NO_LOCALE
  2644. { "locale", SHOLOC,0 },
  2645. #endif /* NO_LOCALE */
  2646. #endif /* NOCSETS */
  2647. { "log", SHLOG, CM_INV|CM_ABR },
  2648. { "logs", SHLOG, 0 },
  2649. #ifndef NOSPL
  2650. { "macros", SHMAC, 0 },
  2651. #endif /* NOSPL */
  2652. #ifndef NODIAL
  2653. { "modem", SHMOD, CM_LOC },
  2654. #else
  2655. { "modem-signals",SHCOM, CM_INV|CM_LOC },
  2656. #endif /* NODIAL */
  2657. #ifndef NOLOCAL
  2658. #ifdef OS2MOUSE
  2659. { "mouse", SHMOU, CM_LOC },
  2660. #endif /* OS2MOUSE */
  2661. #endif /* NOLOCAL */
  2662. #ifdef NETCONN
  2663. { "network", SHNET, CM_LOC },
  2664. #else
  2665. { "network", SHNET, CM_INV|CM_LOC },
  2666. #endif /* NETCONN */
  2667. { "options", SHOPTS, 0 },
  2668. #ifndef NOSPL
  2669. { "output", SHOUTP, CM_INV },
  2670. #endif /* NOSPL */
  2671. #ifdef ANYX25
  2672. #ifndef IBMX25
  2673. { "pad", SHPAD, CM_LOC },
  2674. #endif /* IBMX25 */
  2675. #endif /* ANYX25 */
  2676. { "parameters", SHPAR, CM_INV },
  2677. #ifdef PATTERNS
  2678. { "patterns", SHOPAT, 0 },
  2679. #endif /* PATTERNS */
  2680. { "printer", SHPRT, 0 },
  2681. #ifdef CK_SPEED
  2682. { "prefixing", SHCTL, CM_INV },
  2683. #endif /* CK_SPEED */
  2684. #ifndef NOXFER
  2685. { "protocol", SHPRO, 0 },
  2686. #endif /* NOXFER */
  2687. { "rename", SHOREN, 0 },
  2688. #ifndef NOSPL
  2689. { "scripts", SHSCR, CM_LOC },
  2690. #endif /* NOSPL */
  2691. { "send-list", SHSFL, 0 },
  2692. #ifndef NOSERVER
  2693. { "server", SHSER, 0 },
  2694. #endif /* NOSERVER */
  2695. #ifndef NOSEXP
  2696. { "sexpression", SHSEXP, 0 },
  2697. #endif /* NOSEXP */
  2698. #ifdef ANYSSH
  2699. { "ssh", SHOSSH, 0 },
  2700. #endif /* ANYSSH */
  2701. { "stack", SHSTK, 0 },
  2702. { "status", SHSTA, 0 },
  2703. #ifdef STREAMING
  2704. { "streaming", SHOSTR, 0 },
  2705. #endif /* STREAMING */
  2706. #ifndef NOLOCAL
  2707. #ifdef OS2
  2708. { "tabs", SHTAB, CM_INV|CM_LOC },
  2709. #endif /* OS2 */
  2710. #ifdef CK_TAPI
  2711. { "tapi", SHTAPI, CM_LOC },
  2712. { "tapi-comm", SHTAPI_C, CM_INV|CM_LOC },
  2713. { "tapi-location", SHTAPI_L, CM_INV|CM_LOC },
  2714. { "tapi-modem", SHTAPI_M, CM_INV|CM_LOC },
  2715. #endif /* CK_TAPI */
  2716. { "tcp", SHTCP, CM_LOC },
  2717. #ifdef TNCODE
  2718. { "tel", SHTEL, CM_INV|CM_ABR },
  2719. { "telnet", SHTEL, 0 },
  2720. { "telopt", SHTOPT, 0 },
  2721. { "temp-directory", SHOTMPDIR, 0 },
  2722. #endif /* TNCODE */
  2723. { "terminal", SHTER, CM_LOC },
  2724. #endif /* NOLOCAL */
  2725. #ifndef NOSPL
  2726. { "tmp-directory", SHOTMPDIR, CM_INV },
  2727. #endif /* NOSPL */
  2728. #ifndef NOXMIT
  2729. { "tr", SHXMI, CM_INV|CM_ABR },
  2730. { "tra", SHXMI, CM_INV|CM_ABR },
  2731. { "tran", SHXMI, CM_INV|CM_ABR },
  2732. { "trans", SHXMI, CM_INV|CM_ABR },
  2733. #endif /* NOXMIT */
  2734. #ifndef NOXFER
  2735. { "transfer", SHOXFER, 0 },
  2736. #endif /* NOXFER */
  2737. #ifndef NOXMIT
  2738. { "transmit", SHXMI, 0 },
  2739. #endif /* NOXMIT */
  2740. #ifdef CK_TRIGGER
  2741. { "trigger", SHTRIG, CM_LOC },
  2742. #endif /* CK_TRIGGER */
  2743. #ifndef NOSETKEY
  2744. #ifndef NOKVERBS
  2745. #ifdef OS2
  2746. { "udk", SHUDK, CM_LOC },
  2747. #endif /* OS2 */
  2748. #endif /* NOKVERBS */
  2749. #endif /* NOSETKEY */
  2750. #ifndef NOSPL
  2751. { "variables", SHBUI, 0 },
  2752. #endif /* NOSPL */
  2753. #ifndef NOFRILLS
  2754. { "versions", SHVER, 0 },
  2755. #endif /* NOFRILLS */
  2756. #ifdef OS2
  2757. { "vscrn", SHVSCRN, CM_INV|CM_LOC },
  2758. #endif /* OS2 */
  2759. { "xfer", SHOXFER, CM_INV },
  2760. #ifndef NOXMIT
  2761. { "xmit", SHXMI, CM_INV },
  2762. #endif /* NOXMIT */
  2763. { "", 0, 0 }
  2764. };
  2765. int nsho = (sizeof(shotab) / sizeof(struct keytab)) - 1;
  2766. #endif /* NOSHOW */
  2767. #ifdef ANYX25
  2768. #ifndef IBMX25
  2769. struct keytab padtab[] = { /* PAD commands */
  2770. { "clear", XYPADL, 0 },
  2771. { "interrupt", XYPADI, 0 },
  2772. { "reset", XYPADR, 0 },
  2773. { "status", XYPADS, 0 }
  2774. };
  2775. int npadc = (sizeof(padtab) / sizeof(struct keytab));
  2776. #endif /* IBMX25 */
  2777. #endif /* ANYX25 */
  2778. #ifndef NOSERVER
  2779. static struct keytab kmstab[] = {
  2780. { "both", 3, 0 },
  2781. { "local", 1, 0 },
  2782. { "remote", 2, 0 }
  2783. };
  2784. static struct keytab enatab[] = { /* ENABLE commands */
  2785. { "all", EN_ALL, 0 },
  2786. #ifndef NOSPL
  2787. { "as", EN_ASG, CM_INV|CM_ABR },
  2788. { "asg", EN_ASG, CM_INV },
  2789. { "assign", EN_ASG, 0 },
  2790. #endif /* NOSPL */
  2791. #ifndef datageneral
  2792. { "bye", EN_BYE, 0 },
  2793. #endif /* datageneral */
  2794. { "cd", EN_CWD, 0 },
  2795. #ifdef ZCOPY
  2796. { "copy", EN_CPY, 0 },
  2797. #endif /* ZCOPY */
  2798. { "cwd", EN_CWD, CM_INV },
  2799. { "delete", EN_DEL, 0 },
  2800. { "directory", EN_DIR, 0 },
  2801. { "enable", EN_ENA, CM_INV },
  2802. { "exit", EN_XIT, 0 },
  2803. { "finish", EN_FIN, 0 },
  2804. { "get", EN_GET, 0 },
  2805. { "host", EN_HOS, 0 },
  2806. { "mail", EN_MAI, 0 },
  2807. { "mkdir", EN_MKD, 0 },
  2808. { "print", EN_PRI, 0 },
  2809. #ifndef NOSPL
  2810. { "query", EN_QUE, 0 },
  2811. #endif /* NOSPL */
  2812. { "rename", EN_REN, 0 },
  2813. { "retrieve", EN_RET, CM_INV },
  2814. { "rmdir", EN_RMD, 0 },
  2815. { "send", EN_SEN, 0 },
  2816. { "set", EN_SET, 0 },
  2817. { "space", EN_SPA, 0 },
  2818. { "type", EN_TYP, 0 },
  2819. { "who", EN_WHO, 0 }
  2820. };
  2821. static int nena = (sizeof(enatab) / sizeof(struct keytab));
  2822. #endif /* NOSERVER */
  2823. struct keytab txtbin[] = {
  2824. { "all", 2, 0 },
  2825. { "binary", 1, 0 },
  2826. { "text", 0, 0 }
  2827. };
  2828. #ifndef NOXFER
  2829. static struct keytab sndtab[] = { /* SEND command options */
  2830. { "/after", SND_AFT, CM_ARG },
  2831. #ifndef NOSPL
  2832. { "/array", SND_ARR, CM_ARG },
  2833. #endif /* NOSPL */
  2834. { "/as-name", SND_ASN, CM_ARG },
  2835. { "/b", SND_BIN, CM_INV|CM_ABR },
  2836. { "/before", SND_BEF, CM_ARG },
  2837. { "/binary", SND_BIN, 0 },
  2838. #ifdef CALIBRATE
  2839. { "/c", SND_CMD, CM_INV|CM_ABR },
  2840. { "/calibrate", SND_CAL, CM_INV|CM_ARG },
  2841. #endif /* CALIBRATE */
  2842. { "/command", SND_CMD, CM_PSH },
  2843. { "/delete", SND_DEL, 0 },
  2844. #ifdef UNIXOROSK
  2845. { "/dotfiles", SND_DOT, 0 },
  2846. #endif /* UNIXOROSK */
  2847. { "/except", SND_EXC, CM_ARG },
  2848. #ifdef PIPESEND
  2849. { "/filter", SND_FLT, CM_ARG|CM_PSH },
  2850. #endif /* PIPESEND */
  2851. { "/filenames", SND_NAM, CM_ARG },
  2852. #ifdef CKSYMLINK
  2853. { "/followlinks", SND_LNK, 0 },
  2854. #endif /* CKSYMLINK */
  2855. #ifdef VMS
  2856. { "/image", SND_IMG, 0 },
  2857. #else
  2858. { "/image", SND_BIN, CM_INV },
  2859. #endif /* VMS */
  2860. #ifdef CK_LABELED
  2861. { "/labeled", SND_LBL, 0 },
  2862. #endif /* CK_LABELED */
  2863. { "/larger-than", SND_LAR, CM_ARG },
  2864. { "/listfile", SND_FIL, CM_ARG },
  2865. #ifndef NOFRILLS
  2866. { "/mail", SND_MAI, CM_ARG },
  2867. #endif /* NOFRILLS */
  2868. #ifdef CK_TMPDIR
  2869. { "/move-to", SND_MOV, CM_ARG },
  2870. #endif /* CK_TMPDIR */
  2871. { "/nobackupfiles", SND_NOB, 0 },
  2872. #ifdef UNIXOROSK
  2873. { "/nodotfiles", SND_NOD, 0 },
  2874. #endif /* UNIXOROSK */
  2875. #ifdef CKSYMLINK
  2876. { "/nofollowlinks", SND_NLK, 0 },
  2877. #endif /* CKSYMLINK */
  2878. { "/not-after", SND_NAF, CM_ARG },
  2879. { "/not-before", SND_NBE, CM_ARG },
  2880. { "/pathnames", SND_PTH, CM_ARG },
  2881. { "/print", SND_PRI, CM_ARG },
  2882. #ifdef CK_XYZ
  2883. { "/protocol", SND_PRO, CM_ARG },
  2884. #else
  2885. { "/protocol", SND_PRO, CM_ARG|CM_INV },
  2886. #endif /* CK_XYZ */
  2887. { "/quiet", SND_SHH, 0 },
  2888. { "/recover", SND_RES, 0 },
  2889. #ifdef RECURSIVE
  2890. /* Systems where we do recursion */
  2891. { "/recursive", SND_REC, 0 },
  2892. #else
  2893. #ifdef VMS
  2894. /* Systems that do recursion themselves without our assistance */
  2895. /* if we give them the right kind of wildcard */
  2896. { "/recursive", SND_REC, 0 },
  2897. #else
  2898. #ifdef datageneral
  2899. { "/recursive", SND_REC, 0 },
  2900. #else
  2901. { "/recursive", SND_REC, CM_INV },
  2902. #endif /* datageneral */
  2903. #endif /* VMS */
  2904. #endif /* RECURSIVE */
  2905. { "/rename-to", SND_REN, CM_ARG },
  2906. { "/since", SND_AFT, CM_INV|CM_ARG },
  2907. { "/smaller-than", SND_SMA, CM_ARG },
  2908. { "/starting-at", SND_STA, CM_ARG },
  2909. #ifndef NOFRILLS
  2910. { "/su", SND_ASN, CM_ARG|CM_INV|CM_ABR },
  2911. { "/sub", SND_ASN, CM_ARG|CM_INV|CM_ABR },
  2912. { "/subject", SND_ASN, CM_ARG },
  2913. #endif /* NOFRILLS */
  2914. #ifdef RECURSIVE
  2915. { "/subdirectories", SND_REC, CM_INV },
  2916. #endif /* RECURSIVE */
  2917. { "/text", SND_TXT, 0 },
  2918. { "/transparent", SND_XPA, 0 },
  2919. { "/type", SND_TYP, CM_ARG }
  2920. };
  2921. #define NSNDTAB sizeof(sndtab)/sizeof(struct keytab)
  2922. static int nsndtab = NSNDTAB;
  2923. #ifndef NOMSEND
  2924. static struct keytab msndtab[] = { /* MSEND options */
  2925. { "/after", SND_AFT, CM_ARG },
  2926. { "/before", SND_BEF, CM_ARG },
  2927. { "/binary", SND_BIN, 0 },
  2928. { "/delete", SND_DEL, 0 },
  2929. { "/except", SND_EXC, CM_ARG },
  2930. { "/filenames", SND_NAM, CM_ARG },
  2931. #ifdef CKSYMLINK
  2932. { "/followlinks", SND_LNK, 0 },
  2933. #endif /* CKSYMLINK */
  2934. #ifdef VMS
  2935. { "/image", SND_IMG, 0 },
  2936. #else
  2937. { "/image", SND_BIN, CM_INV },
  2938. #endif /* VMS */
  2939. #ifdef CK_LABELED
  2940. { "/labeled", SND_LBL, 0 },
  2941. #endif /* CK_LABELED */
  2942. { "/larger-than", SND_LAR, CM_ARG },
  2943. { "/list", SND_FIL, CM_ARG },
  2944. #ifndef NOFRILLS
  2945. { "/mail", SND_MAI, CM_ARG },
  2946. #endif /* NOFRILLS */
  2947. #ifdef CK_TMPDIR
  2948. { "/move-to", SND_MOV, CM_ARG },
  2949. #endif /* CK_TMPDIR */
  2950. #ifdef CKSYMLINK
  2951. { "/nofollowlinks", SND_NLK, 0 },
  2952. #endif /* CKSYMLINK */
  2953. { "/not-after", SND_NAF, CM_ARG },
  2954. { "/not-before", SND_NBE, CM_ARG },
  2955. { "/pathnames", SND_PTH, CM_ARG },
  2956. { "/print", SND_PRI, CM_ARG },
  2957. #ifdef CK_XYZ
  2958. { "/protocol", SND_PRO, CM_ARG },
  2959. #endif /* CK_XYZ */
  2960. { "/quiet", SND_SHH, 0 },
  2961. { "/recover", SND_RES, 0 },
  2962. { "/rename-to", SND_REN, CM_ARG },
  2963. { "/since", SND_AFT, CM_INV|CM_ARG },
  2964. { "/smaller-than", SND_SMA, CM_ARG },
  2965. { "/starting-at", SND_STA, CM_ARG },
  2966. #ifndef NOFRILLS
  2967. { "/subject", SND_ASN, CM_ARG },
  2968. #endif /* NOFRILLS */
  2969. { "/text", SND_TXT, 0 },
  2970. { "/transparent", SND_XPA, 0 },
  2971. { "/type", SND_TYP, CM_ARG }
  2972. };
  2973. #define NMSNDTAB sizeof(msndtab)/sizeof(struct keytab)
  2974. static int nmsndtab = NMSNDTAB;
  2975. #endif /* NOMSEND */
  2976. #endif /* NOXFER */
  2977. /* CONNECT command switches */
  2978. #define CONN_II 0 /* Idle interval */
  2979. #define CONN_IS 1 /* Idle string */
  2980. #define CONN_IL 2 /* Idle limit */
  2981. #define CONN_NV 3 /* Non-Verbose */
  2982. #define CONN_TL 4 /* Time limit */
  2983. #define CONN_TS 5 /* Trigger string */
  2984. #define CONN_AS 6 /* Asynchronous */
  2985. #define CONN_SY 7 /* Synchronous */
  2986. #define CONN_MAX 7 /* Number of CONNECT switches */
  2987. #ifndef NOLOCAL
  2988. static struct keytab conntab[] = {
  2989. #ifdef OS2
  2990. { "/asynchronous", CONN_AS, CM_INV },
  2991. #endif /* OS2 */
  2992. #ifdef XLIMITS
  2993. { "/idle-interval", CONN_II, CM_ARG },
  2994. { "/idle-limit", CONN_IL, CM_ARG },
  2995. { "/idle-string", CONN_IS, CM_ARG },
  2996. { "/quietly", CONN_NV, CM_INV },
  2997. #else
  2998. { "/quietly", CONN_NV, 0 },
  2999. #endif /* XLIMITS */
  3000. #ifdef OS2
  3001. { "/synchronous", CONN_SY, CM_INV },
  3002. #endif /* OS2 */
  3003. #ifdef XLIMITS
  3004. { "/time-limit", CONN_TL, CM_ARG },
  3005. #endif /* XLIMITS */
  3006. #ifdef CK_TRIGGER
  3007. { "/trigger", CONN_TS, CM_ARG },
  3008. #endif /* CK_TRIGGER */
  3009. { "",0,0 }
  3010. };
  3011. #define NCONNTAB sizeof(conntab)/sizeof(struct keytab)
  3012. static int nconntab = NCONNTAB;
  3013. #endif /* NOLOCAL */
  3014. #ifndef NOXFER
  3015. static struct keytab stattab[] = { /* STATISTICS command switches */
  3016. { "/brief", 1, 0 },
  3017. { "/verbose", 0, 0 }
  3018. };
  3019. #endif /* NOXFER */
  3020. #ifndef NOSPL
  3021. #ifdef COMMENT
  3022. struct mtab mactab[MAC_MAX] = { /* Preinitialized macro table */
  3023. { NULL, NULL, 0 }
  3024. };
  3025. #else
  3026. struct mtab *mactab; /* Dynamically allocated macro table */
  3027. #endif /* COMMENT */
  3028. int nmac = 0;
  3029. struct keytab mackey[MAC_MAX]; /* Macro names as command keywords */
  3030. #endif /* NOSPL */
  3031. #ifndef NOSPL
  3032. #ifdef OS2
  3033. struct keytab beeptab[] = { /* Beep options */
  3034. { "error", BP_FAIL, 0 },
  3035. { "information", BP_NOTE, 0 },
  3036. { "warning", BP_WARN, 0 }
  3037. };
  3038. int nbeeptab = sizeof(beeptab)/sizeof(struct keytab);
  3039. /* CLEAR COMMMAND-SCREEN options */
  3040. #define CLR_C_ALL 0
  3041. #define CLR_C_BOL 1
  3042. #define CLR_C_BOS 2
  3043. #define CLR_C_EOL 3
  3044. #define CLR_C_EOS 4
  3045. #define CLR_C_LIN 5
  3046. #define CLR_C_SCR 6
  3047. struct keytab clrcmdtab[] = {
  3048. { "all", CLR_C_ALL, 0 },
  3049. { "bol", CLR_C_BOL, 0 },
  3050. { "bos", CLR_C_BOS, 0 },
  3051. { "eol", CLR_C_EOL, 0 },
  3052. { "eos", CLR_C_EOS, 0 },
  3053. { "line", CLR_C_LIN, 0 },
  3054. { "scrollback", CLR_C_SCR, 0 }
  3055. };
  3056. int nclrcmd = sizeof(clrcmdtab)/sizeof(struct keytab);
  3057. #endif /* OS2 */
  3058. #endif /* NOSPL */
  3059. #ifdef COMMENT
  3060. /* Not used at present */
  3061. static struct keytab pagetab[] = {
  3062. { "/more", 1, CM_INV },
  3063. { "/nopage", 0, 0 },
  3064. { "/page", 1, 0 }
  3065. };
  3066. int npagetab = sizeof(pagetab)/sizeof(struct keytab);
  3067. #endif /* COMMENT */
  3068. #define TYP_NOP 0 /* /NOPAGE */
  3069. #define TYP_PAG 1 /* /PAGE */
  3070. #define TYP_HEA 2 /* /HEAD:n */
  3071. #define TYP_TAI 3 /* /TAIL:n */
  3072. #define TYP_PAT 4 /* /MATCH:pattern */
  3073. #define TYP_WID 5 /* /WIDTH:cols */
  3074. #define TYP_COU 6 /* /COUNT */
  3075. #define TYP_OUT 7 /* /OUTPUT:file */
  3076. #define TYP_PFX 8 /* /PREFIX:string */
  3077. #ifdef UNICODE
  3078. #define TYP_XIN 9 /* /TRANSLATE-FROM:charset */
  3079. #define TYP_XUT 10 /* /TRANSLATE-TO:charset */
  3080. #define TYP_XPA 11 /* /TRANSPARENT */
  3081. #endif /* UNICODE */
  3082. #ifdef KUI
  3083. #define TYP_GUI 12 /* /GUI:title */
  3084. #define TYP_HIG 13 /* /HEIGHT:rows */
  3085. #endif /* KUI */
  3086. #define TYP_NUM 14 /* /NUMBER */
  3087. static struct keytab typetab[] = { /* TYPE command switches */
  3088. { "/count", TYP_COU, 0 },
  3089. #ifdef UNICODE
  3090. { "/character-set", TYP_XIN, CM_ARG },
  3091. #endif /* UNICODE */
  3092. #ifdef KUI
  3093. { "/gui", TYP_GUI, CM_ARG },
  3094. #endif /* KUI */
  3095. { "/head", TYP_HEA, CM_ARG },
  3096. #ifdef KUI
  3097. { "/height", TYP_HIG, CM_ARG },
  3098. #endif /* KUI */
  3099. { "/match", TYP_PAT, CM_ARG },
  3100. #ifdef CK_TTGWSIZ
  3101. { "/more", TYP_PAG, CM_INV },
  3102. { "/nopage", TYP_NOP, 0 },
  3103. { "/number", TYP_NUM, 0 },
  3104. { "/output", TYP_OUT, CM_ARG },
  3105. { "/page", TYP_PAG, 0 },
  3106. #endif /* CK_TTGWSIZ */
  3107. { "/prefix", TYP_PFX, CM_ARG },
  3108. { "/tail", TYP_TAI, CM_ARG },
  3109. #ifdef UNICODE
  3110. { "/translate-to", TYP_XUT, CM_ARG },
  3111. { "/transparent", TYP_XPA, 0 },
  3112. #endif /* UNICODE */
  3113. { "/width", TYP_WID, CM_ARG },
  3114. #ifdef UNICODE
  3115. { "/xlate-to", TYP_XUT, CM_INV|CM_ARG },
  3116. #endif /* UNICODE */
  3117. { "", 0, 0 }
  3118. };
  3119. int ntypetab = sizeof(typetab)/sizeof(struct keytab) - 1;
  3120. int typ_page = -1; /* TYPE /[NO]PAGE default */
  3121. int typ_wid = -1;
  3122. #ifndef NOSPL
  3123. #define TRA_ALL 999 /* TRACE command */
  3124. #define TRA_ASG 0
  3125. #define TRA_CMD 1
  3126. int tra_asg = 0;
  3127. int tra_cmd = 0;
  3128. static struct keytab tracetab[] = { /* TRACE options */
  3129. { "all", TRA_ALL, 0 },
  3130. { "assignments", TRA_ASG, 0 },
  3131. { "command-level", TRA_CMD, 0 }
  3132. };
  3133. static int ntracetab = sizeof(tracetab)/sizeof(struct keytab);
  3134. #endif /* NOSPL */
  3135. #ifndef NOSHOW
  3136. VOID
  3137. showtypopts() {
  3138. printf(" TYPE ");
  3139. if (typ_page > -1) {
  3140. prtopt(&optlines,typ_page ? "/PAGE" : "/NOPAGE");
  3141. } else
  3142. prtopt(&optlines,"(no options set)");
  3143. if (typ_wid > -1) {
  3144. ckmakmsg(tmpbuf,TMPBUFSIZ,"/WIDTH:",ckitoa(typ_wid),NULL,NULL);
  3145. prtopt(&optlines,tmpbuf);
  3146. }
  3147. prtopt(&optlines,"");
  3148. }
  3149. #endif /* NOSHOW */
  3150. #ifdef LOCUS
  3151. /* isauto == 1 if locus is being switched automatically */
  3152. VOID
  3153. setlocus(x, isauto) int x, isauto; {
  3154. extern int quitting;
  3155. if (x) x = 1;
  3156. if (x && locus) return;
  3157. if (!x && !locus) return;
  3158. /* Get here if it actually needs to be changed */
  3159. #ifdef OS2
  3160. if (isauto && /* Automatically switching */
  3161. !quitting && /* not exiting */
  3162. autolocus == 2) { /* and AUTOLOCUS is set to ASK */
  3163. char locmsg[300];
  3164. ckmakmsg(locmsg,300,
  3165. "Switching Locus to ",
  3166. x ? "LOCAL" : "REMOTE",
  3167. " for file management commands\n"
  3168. "such as CD, DIRECTORY, DELETE, RENAME. Type HELP SET\n"
  3169. "LOCUS at the K-95> prompt for further info. Use the\n"
  3170. #ifdef KUI
  3171. "Actions menu or SET LOCUS command to disable automatic\n"
  3172. "Locus switching or to disable these queries.",
  3173. #else /* KUI */
  3174. "SET LOCUS command to disable automatic locus switching\n"
  3175. "or to disable these queries.",
  3176. #endif /* KUI */
  3177. NULL);
  3178. if (uq_ok(locmsg,"OK to switch Locus?",3,NULL,1)) {
  3179. locus = x;
  3180. #ifdef KUI
  3181. KuiSetProperty(KUI_LOCUS,x,0);
  3182. #endif /* KUI */
  3183. return;
  3184. }
  3185. } else {
  3186. #endif /* OS2 */
  3187. if (isauto && msgflg && !quitting)
  3188. printf("Switching LOCUS for file-management commands to %s %s.\n",
  3189. x ? "LOCAL" : "REMOTE",
  3190. "(HELP LOCUS for info)"
  3191. );
  3192. locus = x;
  3193. #ifdef OS2
  3194. #ifdef KUI
  3195. KuiSetProperty(KUI_LOCUS,x,0);
  3196. #endif /* KUI */
  3197. }
  3198. #endif /* OS2 */
  3199. }
  3200. VOID
  3201. setautolocus(x) int x; {
  3202. autolocus = x;
  3203. #ifdef KUI
  3204. KuiSetProperty(KUI_AUTO_LOCUS,x,0);
  3205. #endif /* KUI */
  3206. }
  3207. #endif /* LOCUS */
  3208. int
  3209. settypopts() { /* Set TYPE option defaults */
  3210. int xp = -1;
  3211. int c, getval;
  3212. while (1) {
  3213. if ((y = cmswi(typetab,ntypetab,"Switch","",xxstring)) < 0) {
  3214. if (y == -3)
  3215. break;
  3216. else
  3217. return(y);
  3218. }
  3219. c = cmgbrk();
  3220. if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
  3221. printf("?This switch does not take an argument\n");
  3222. return(-9);
  3223. }
  3224. switch (y) {
  3225. case TYP_NOP: xp = 0; break;
  3226. case TYP_PAG: xp = 1; break;
  3227. case TYP_WID:
  3228. if (getval)
  3229. if ((x = cmnum("Column at which to truncate",
  3230. ckitoa(cmd_cols),10,&y,xxstring)) < 0)
  3231. return(x);
  3232. typ_wid = y;
  3233. break;
  3234. default:
  3235. printf("?Sorry, this option can not be set\n");
  3236. return(-9);
  3237. }
  3238. }
  3239. if ((x = cmcfm()) < 0) /* Get confirmation */
  3240. return(x);
  3241. if (xp > -1) typ_page = xp; /* Confirmed, save defaults */
  3242. return(success = 1);
  3243. }
  3244. _PROTOTYP (char * getbasename, ( char * ) );
  3245. /* Forward declarations of functions local to this module */
  3246. #ifdef UNIX
  3247. _PROTOTYP (int douchmod, ( void ) );
  3248. #endif /* UNIX */
  3249. #ifdef CKPURGE
  3250. _PROTOTYP (int dopurge, ( void ) );
  3251. #endif /* CKPURGE */
  3252. #ifndef NOSPL
  3253. _PROTOTYP (int doundef, ( int ) );
  3254. _PROTOTYP (int doask, ( int ) );
  3255. _PROTOTYP (int dodef, ( int ) );
  3256. _PROTOTYP (int doelse, ( void ) );
  3257. _PROTOTYP (int dofor, ( void ) );
  3258. #endif /* NOSPL */
  3259. #ifndef NODIAL
  3260. _PROTOTYP (int dodial, ( int ) );
  3261. #endif /* NODIAL */
  3262. _PROTOTYP (int dodel, ( void ) );
  3263. _PROTOTYP (int dopaus, ( int ) );
  3264. #ifndef NOPUSH
  3265. #ifdef TCPSOCKET
  3266. _PROTOTYP (int doping, ( void ) );
  3267. _PROTOTYP (int doftp, ( void ) );
  3268. #endif /* TCPSOCKET */
  3269. #endif /* NOPUSH */
  3270. #ifndef NORENAME
  3271. #ifndef NOFRILLS
  3272. _PROTOTYP (int dorenam, ( void ) );
  3273. #endif /* NOFRILLS */
  3274. #endif /* NORENAME */
  3275. #ifdef ZCOPY
  3276. _PROTOTYP (int docopy, ( void ) );
  3277. #endif /* ZCOPY */
  3278. #ifdef NT
  3279. _PROTOTYP (int dolink, ( void ));
  3280. #endif /* NT */
  3281. #ifdef CK_REXX
  3282. _PROTOTYP (int dorexx, ( void ) );
  3283. #endif /* CK_REXX */
  3284. #ifdef TNCODE
  3285. static struct keytab telcmd[] = {
  3286. { "abort", TN_ABORT, CM_INV }, /* Emotionally toned - don't show */
  3287. { "ao", TN_AO, 0 },
  3288. { "ayt", TN_AYT, 0 },
  3289. { "break", BREAK, 0 },
  3290. { "cancel",TN_ABORT, 0 },
  3291. { "dmark", TN_DM, 0 },
  3292. { "do", DO, 0 },
  3293. { "dont", DONT, 0 },
  3294. { "ec", TN_EC, 0 },
  3295. { "el", TN_EL, 0 },
  3296. { "eof", TN_EOF, 0 },
  3297. { "eor", TN_EOR, 0 },
  3298. #ifdef CK_KERBEROS
  3299. #ifdef KRB5
  3300. #define TN_FWD 1
  3301. { "forward", TN_FWD, CM_INV },
  3302. #endif /* KRB5 */
  3303. #endif /* CK_KERBEROS */
  3304. { "ga", TN_GA, 0 },
  3305. { "ip", TN_IP, 0 },
  3306. { "nop", TN_NOP, 0 },
  3307. { "sak", TN_SAK, CM_INV },
  3308. { "sb", SB, 0 },
  3309. { "se", SE, 0 },
  3310. { "susp", TN_SUSP, 0 },
  3311. { "will", WILL, 0 },
  3312. { "wont", WONT, 0 }
  3313. };
  3314. static int ntelcmd = (sizeof(telcmd) / sizeof(struct keytab));
  3315. static struct keytab tnopts[] = {
  3316. #ifdef CK_AUTHENTICATION
  3317. { "auth", TELOPT_AUTHENTICATION, 0 },
  3318. #else
  3319. { "auth", TELOPT_AUTHENTICATION, CM_INV },
  3320. #endif /* CK_AUTHENTICATION */
  3321. { "binary", TELOPT_BINARY, 0 },
  3322. #ifdef TN_COMPORT
  3323. { "c", TELOPT_COMPORT, CM_INV|CM_ABR},
  3324. { "co", TELOPT_COMPORT, CM_INV|CM_ABR},
  3325. { "com", TELOPT_COMPORT, CM_INV|CM_ABR},
  3326. { "com-port-control", TELOPT_COMPORT, 0 },
  3327. { "comport-control", TELOPT_COMPORT, CM_INV},
  3328. #else /* TN_COMPORT */
  3329. { "com-port-control", TELOPT_COMPORT, CM_INV },
  3330. { "comport-control", TELOPT_COMPORT, CM_INV},
  3331. #endif /* TN_COMPORT */
  3332. { "echo", TELOPT_ECHO, 0 },
  3333. #ifdef CK_ENCRYPTION
  3334. { "encrypt", TELOPT_ENCRYPTION, 0 },
  3335. #else
  3336. { "encrypt", TELOPT_ENCRYPTION, CM_INV },
  3337. #endif /* CK_ENCRYPTION */
  3338. #ifdef CK_FORWARD_X
  3339. { "forward-x", TELOPT_FORWARD_X, 0 },
  3340. #else
  3341. { "forward-x", TELOPT_FORWARD_X, CM_INV },
  3342. #endif /* CK_FORWARD_X */
  3343. #ifdef IKS_OPTION
  3344. { "kermit", TELOPT_KERMIT, 0 },
  3345. #else
  3346. { "kermit", TELOPT_KERMIT, CM_INV },
  3347. #endif /* IKS_OPTION */
  3348. { "lflow", TELOPT_LFLOW, CM_INV },
  3349. { "logout", TELOPT_LOGOUT, CM_INV },
  3350. #ifdef CK_NAWS
  3351. { "naws", TELOPT_NAWS, 0 },
  3352. #else
  3353. { "naws", TELOPT_NAWS, CM_INV },
  3354. #endif /* CK_NAWS */
  3355. #ifdef CK_ENVIRONMENT
  3356. { "new-environment", TELOPT_NEWENVIRON, 0 },
  3357. #else
  3358. { "new-environment", TELOPT_NEWENVIRON, CM_INV },
  3359. #endif /* CK_ENVIRONMENT */
  3360. { "pragma-heartbeat",TELOPT_PRAGMA_HEARTBEAT, CM_INV },
  3361. { "pragma-logon", TELOPT_PRAGMA_LOGON, CM_INV },
  3362. { "pragma-sspi", TELOPT_SSPI_LOGON, CM_INV },
  3363. { "sak", TELOPT_IBM_SAK, CM_INV },
  3364. #ifdef CK_SNDLOC
  3365. { "send-location", TELOPT_SNDLOC, 0 },
  3366. #else
  3367. { "send-location", TELOPT_SNDLOC, CM_INV },
  3368. #endif /* CK_SNDLOC */
  3369. { "sga", TELOPT_SGA, 0 },
  3370. #ifdef CK_SSL
  3371. { "start-tls", TELOPT_START_TLS, 0 },
  3372. #else
  3373. { "start-tls", TELOPT_START_TLS, CM_INV },
  3374. #endif /* CK_SSL */
  3375. { "ttype", TELOPT_TTYPE, 0 },
  3376. #ifdef CK_ENVIRONMENT
  3377. { "xdisplay-location", TELOPT_XDISPLOC, 0 },
  3378. #else
  3379. { "xdisplay-location", TELOPT_XDISPLOC, CM_INV },
  3380. #endif /* CK_ENVIRONMENT */
  3381. { "", 0, 0 }
  3382. };
  3383. static int ntnopts = (sizeof(tnopts) / sizeof(struct keytab)) - 1;
  3384. static struct keytab tnsbopts[] = {
  3385. #ifdef CK_NAWS
  3386. { "naws", TELOPT_NAWS, 0 },
  3387. #endif /* CK_NAWS */
  3388. { "", 0, 0 }
  3389. };
  3390. static int ntnsbopts = (sizeof(tnsbopts) / sizeof(struct keytab)) - 1;
  3391. #endif /* TNCODE */
  3392. #ifdef TCPSOCKET
  3393. #ifndef NOPUSH
  3394. #ifdef SYSFTP
  3395. int
  3396. doftp() { /* (External) FTP command */
  3397. char *p, *f; /* (See doxftp() for internal one) */
  3398. int x;
  3399. if (network) /* If we have a current connection */
  3400. ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */
  3401. else *line = '\0'; /* as default host */
  3402. for (p = line; *p; p++) /* Remove ":service" from end. */
  3403. if (*p == ':') { *p = '\0'; break; }
  3404. if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3405. return(x);
  3406. if (nopush) {
  3407. printf("?Sorry, FTP command disabled\n");
  3408. return(success = 0);
  3409. }
  3410. /* Construct FTP command */
  3411. #ifdef VMS
  3412. #ifdef MULTINET /* TGV MultiNet */
  3413. ckmakmsg(line,LINBUFSIZ,"multinet ftp ",s,NULL,NULL);
  3414. #else
  3415. ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3416. #endif /* MULTINET */
  3417. #else /* Not VMS */
  3418. #ifdef OS2ORUNIX
  3419. #ifndef NOFTP
  3420. f = ftpapp;
  3421. if (!f) f = "";
  3422. if (!f[0]) f = "ftp";
  3423. ckmakmsg(line,LINBUFSIZ,f," ",s,NULL);
  3424. #ifdef OS2
  3425. p = line + strlen(ftpapp);
  3426. while (p != line) {
  3427. if (*p == '/') *p = '\\';
  3428. p--;
  3429. }
  3430. #endif /* OS2 */
  3431. #else /* NOFTP */
  3432. ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3433. #endif /* NOFTP */
  3434. #else /* OS2ORUNIX */
  3435. ckmakmsg(line,LINBUFSIZ,"ftp ",s,NULL,NULL);
  3436. #endif /* OS2ORUNIX */
  3437. #endif /* VMS */
  3438. conres(); /* Make console normal */
  3439. #ifdef DEC_TCPIP
  3440. printf("\n"); /* Prevent prompt-stomping */
  3441. #endif /* DEC_TCPIP */
  3442. x = zshcmd(line);
  3443. concb((char)escape);
  3444. return(success = x);
  3445. }
  3446. #endif /* SYSFTP */
  3447. int
  3448. doping() { /* PING command */
  3449. char *p; /* just runs ping program */
  3450. int x;
  3451. if (network) /* If we have a current connection */
  3452. ckstrncpy(line,ttname,LINBUFSIZ); /* get the host name */
  3453. else *line = '\0'; /* as default host to be pinged. */
  3454. for (p = line; *p; p++) /* Remove ":service" from end. */
  3455. if (*p == ':') { *p = '\0'; break; }
  3456. if ((x = cmtxt("IP host name or number", line, &s, xxstring)) < 0)
  3457. return(x);
  3458. if (nopush) {
  3459. printf("?Sorry, PING command disabled\n");
  3460. return(success = 0);
  3461. }
  3462. /* Construct PING command */
  3463. #ifdef VMS
  3464. #ifdef MULTINET /* TGV MultiNet */
  3465. ckmakmsg(line,LINBUFSIZ,"multinet ping ",s," /num=1",NULL);
  3466. #else
  3467. ckmakmsg(line,LINBUFSIZ,"ping ",s," 56 1",NULL); /* Other VMS TCP/IP's */
  3468. #endif /* MULTINET */
  3469. #else /* Not VMS */
  3470. ckmakmsg(line,LINBUFSIZ,"ping ",s,NULL,NULL);
  3471. #endif /* VMS */
  3472. conres(); /* Make console normal */
  3473. #ifdef DEC_TCPIP
  3474. printf("\n"); /* Prevent prompt-stomping */
  3475. #endif /* DEC_TCPIP */
  3476. x = zshcmd(line);
  3477. concb((char)escape);
  3478. return(success = x);
  3479. }
  3480. #endif /* NOPUSH */
  3481. #endif /* TCPSOCKET */
  3482. static VOID
  3483. doend(x) int x; {
  3484. #ifndef NOSPL
  3485. /* Pop from all FOR/WHILE/XIF/SWITCH's */
  3486. debug(F101,"doend maclvl 1","",maclvl);
  3487. while ((maclvl > 0) &&
  3488. (m_arg[maclvl-1][0]) &&
  3489. (cmdstk[cmdlvl].src == CMD_MD) &&
  3490. (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
  3491. !strncmp(m_arg[maclvl-1][0],"_for",4) ||
  3492. !strncmp(m_arg[maclvl-1][0],"_whi",4) ||
  3493. !strncmp(m_arg[maclvl-1][0],"_swi",4))) {
  3494. debug(F110,"END popping",m_arg[maclvl-1][0],0);
  3495. dogta(XXPTA); /* Put args back */
  3496. popclvl(); /* Pop up two levels */
  3497. popclvl();
  3498. debug(F101,"doend maclvl 2","",maclvl);
  3499. }
  3500. if (maclvl > -1) {
  3501. if (mrval[maclvl]) /* Free previous retval if any */
  3502. free(mrval[maclvl]);
  3503. mrval[maclvl] = malloc(16); /* Room for up to 15 digits */
  3504. if (mrval[maclvl]) /* Record current retval */
  3505. ckmakmsg(mrval[maclvl],16,ckitoa(x),NULL,NULL,NULL);
  3506. }
  3507. #endif /* NOSPL */
  3508. popclvl(); /* Now pop out of macro or TAKE file */
  3509. #ifndef NOSPL
  3510. #ifdef DEBUG
  3511. if (deblog) {
  3512. debug(F101,"END maclvl 3","",maclvl);
  3513. debug(F111,"END mrval[maclvl]",mrval[maclvl],maclvl);
  3514. debug(F111,"END mrval[maclvl+1]",mrval[maclvl+1],maclvl+1);
  3515. }
  3516. #endif /* DEBUG */
  3517. #endif /* NOSPL */
  3518. }
  3519. #ifdef CKROOT
  3520. int
  3521. dochroot() {
  3522. if ((x = cmdir("Name of new root directory","",&s,xxstring)) < 0) {
  3523. if (x == -3) {
  3524. printf("?Directory name required\n");
  3525. return(-9);
  3526. }
  3527. return(x);
  3528. }
  3529. ckstrncpy(line,s,LINBUFSIZ);
  3530. s = line;
  3531. if ((x = cmcfm()) < 0) return(x);
  3532. s = brstrip(s);
  3533. x = zsetroot(s);
  3534. if (x < 0) {
  3535. char * m = NULL;
  3536. switch (x) {
  3537. case -1:
  3538. case -2: m = "Not a directory"; break;
  3539. case -3: m = "Internal error"; break;
  3540. case -4: m = "Access denied"; break;
  3541. case -5: m = "Off limits"; break;
  3542. }
  3543. if (m) printf("%s: \"%s\"\n", m, s);
  3544. return(m ? -9 : -2);
  3545. } else {
  3546. nopush = 1;
  3547. return(success = 1);
  3548. }
  3549. }
  3550. #endif /* CKROOT */
  3551. #ifndef NOXFER
  3552. static char * asnbuf = NULL; /* As-name buffer pointer */
  3553. char sndxnam[] = { "_array_x_" }; /* (with replaceable x!) */
  3554. /*
  3555. The new SEND command, replacing BSEND, CSEND, PSEND, etc etc.
  3556. Call with cx = top-level keyword value. Returns:
  3557. < 0 On parse error.
  3558. 0 On other type of failure (e.g. requested operation not allowed).
  3559. 1 On success with sstate set to 's' so protocol will begin.
  3560. */
  3561. /* D O X S E N D -- Parse SEND and related commands with switches */
  3562. int
  3563. doxsend(cx) int cx; {
  3564. int c, i, n, wild, confirmed = 0; /* Workers */
  3565. int x, y; /* of the world... */
  3566. int getval = 0; /* Whether to get switch value */
  3567. extern char * snd_move; /* Directory to move sent files to */
  3568. extern char * snd_rename; /* What to rename sent files to */
  3569. extern char * filefile; /* File containing filenames to send */
  3570. extern int xfiletype; /* Send only text (or binary) files */
  3571. extern struct keytab pathtab[]; /* PATHNAMES option keywords */
  3572. extern int npathtab; /* How many of them */
  3573. extern int recursive; /* Recursive directory traversal */
  3574. extern int rprintf; /* REMOTE PRINT flag */
  3575. extern int fdispla; /* TRANSFER DISPLAY setting */
  3576. extern int skipbup; /* Skip backup files when sending */
  3577. struct stringint pv[SND_MAX+1]; /* Temporary array for switch values */
  3578. struct FDB sf, sw, fl, cm; /* FDBs for each parse function */
  3579. int mlist = 0; /* Flag for MSEND or MMOVE */
  3580. char * m; /* For making help messages */
  3581. extern struct keytab protos[]; /* File transfer protocols */
  3582. extern int xfrxla, g_xfrxla, nprotos;
  3583. extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */
  3584. extern char sndnbefore[], sndnafter[];
  3585. extern CK_OFF_T sndsmaller, sndlarger, calibrate;
  3586. #ifndef NOSPL
  3587. int range[2]; /* Array range */
  3588. char ** ap = NULL; /* Array pointer */
  3589. int arrayx = -1; /* Array index */
  3590. #endif /* NOSPL */
  3591. #ifdef NEWFTP
  3592. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  3593. if (cx == XXMAI) {
  3594. printf("?Sorry, No MAIL with FTP\n");
  3595. return(-9);
  3596. }
  3597. return(doftpput(cx,0));
  3598. }
  3599. #endif /* NEWFTP */
  3600. for (i = 0; i <= SND_MAX; i++) { /* Initialize switch values */
  3601. pv[i].sval = NULL; /* to null pointers */
  3602. pv[i].ival = -1; /* and -1 int values */
  3603. pv[i].wval = (CK_OFF_T)-1; /* and -1 wide values */
  3604. }
  3605. #ifndef NOSPL
  3606. range[0] = -1;
  3607. range[1] = -1;
  3608. sndxin = -1; /* Array index */
  3609. #endif /* NOSPL */
  3610. sndarray = NULL; /* Array pointer */
  3611. #ifdef UNIXOROSK
  3612. g_matchdot = matchdot; /* Match dot files */
  3613. #endif /* UNIXOROSK */
  3614. g_recursive = recursive; /* Recursive sending */
  3615. recursive = 0; /* Save global value, set local */
  3616. debug(F101,"xsend entry fncnv","",fncnv);
  3617. /* Preset switch values based on top-level command that called us */
  3618. switch (cx) {
  3619. case XXMSE: /* MSEND */
  3620. mlist = 1; break;
  3621. case XXCSEN: /* CSEND */
  3622. pv[SND_CMD].ival = 1; break;
  3623. case XXMMOVE: /* MMOVE */
  3624. mlist = 1;
  3625. case XXMOVE: /* MOVE */
  3626. pv[SND_DEL].ival = 1; break;
  3627. case XXRSEN: /* RESEND */
  3628. pv[SND_BIN].ival = 1; /* Implies /BINARY */
  3629. pv[SND_RES].ival = 1; break;
  3630. case XXMAI: /* MAIL */
  3631. pv[SND_MAI].ival = 1; break;
  3632. }
  3633. /* Set up chained parse functions... */
  3634. cmfdbi(&sw, /* First FDB - command switches */
  3635. _CMKEY, /* fcode */
  3636. "Filename, or switch", /* hlpmsg */
  3637. "", /* default */
  3638. "", /* addtl string data */
  3639. #ifdef NOMSEND
  3640. nsndtab, /* addtl numeric data 1: tbl size */
  3641. #else
  3642. mlist ? nmsndtab : nsndtab, /* addtl numeric data 1: tbl size */
  3643. #endif /* NOMSEND */
  3644. 4, /* addtl numeric data 2: 4 = cmswi */
  3645. xxstring, /* Processing function */
  3646. #ifdef NOMSEND
  3647. sndtab, /* Keyword table */
  3648. #else
  3649. mlist ? msndtab : sndtab,
  3650. #endif /* NOMSEND */
  3651. &sf /* Pointer to next FDB */
  3652. );
  3653. cmfdbi(&sf, /* 2nd FDB - file to send */
  3654. _CMIFI, /* fcode */
  3655. "File(s) to send", /* hlpmsg */
  3656. "", /* default */
  3657. "", /* addtl string data */
  3658. nolinks, /* addtl numeric data 1 */
  3659. 0, /* addtl numeric data 2 */
  3660. xxstring,
  3661. NULL,
  3662. mlist ? &cm : &fl
  3663. );
  3664. cmfdbi(&fl, /* 3rd FDB - command to send from */
  3665. _CMFLD, /* fcode */
  3666. "Command", /* hlpmsg */
  3667. "", /* default */
  3668. "", /* addtl string data */
  3669. 0, /* addtl numeric data 1 */
  3670. 0, /* addtl numeric data 2 */
  3671. xxstring,
  3672. NULL,
  3673. &cm
  3674. );
  3675. cmfdbi(&cm, /* 4th FDB - Confirmation */
  3676. _CMCFM, /* fcode */
  3677. "", /* hlpmsg */
  3678. "", /* default */
  3679. "", /* addtl string data */
  3680. 0, /* addtl numeric data 1 */
  3681. 0, /* addtl numeric data 2 */
  3682. NULL,
  3683. NULL,
  3684. NULL
  3685. );
  3686. while (1) { /* Parse 0 or more switches */
  3687. x = cmfdb(&sw); /* Parse something */
  3688. debug(F101,"xsend cmfdb","",x);
  3689. if (x < 0) /* Error */
  3690. goto xsendx; /* or reparse needed */
  3691. if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
  3692. break;
  3693. /*
  3694. They gave a switch, but let's see how they terminated it.
  3695. If they ended it with : or =, then we must parse a value.
  3696. If they ended it with anything else, then we must NOT parse a value.
  3697. */
  3698. c = cmgbrk(); /* Get break character */
  3699. getval = (c == ':' || c == '='); /* to see how they ended the switch */
  3700. if (getval && !(cmresult.kflags & CM_ARG)) {
  3701. printf("?This switch does not take arguments\n");
  3702. x = -9;
  3703. goto xsendx;
  3704. }
  3705. if (!getval && (cmgkwflgs() & CM_ARG)) {
  3706. printf("?This switch requires an argument\n");
  3707. x = -9;
  3708. goto xsendx;
  3709. }
  3710. n = cmresult.nresult; /* Numeric result = switch value */
  3711. debug(F101,"xsend switch","",n);
  3712. switch (n) { /* Process the switch */
  3713. case SND_CMD: /* These take no args */
  3714. if (nopush) {
  3715. printf("?Sorry, system command access is disabled\n");
  3716. x = -9;
  3717. goto xsendx;
  3718. }
  3719. #ifdef PIPESEND
  3720. else if (sndfilter) {
  3721. printf(
  3722. "?Sorry, no SEND /COMMAND or CSEND when SEND FILTER selected\n");
  3723. x = -9;
  3724. goto xsendx;
  3725. }
  3726. #endif /* PIPESEND */
  3727. sw.hlpmsg = "Command, or switch"; /* Change help message */
  3728. pv[n].ival = 1; /* Just set the flag */
  3729. pv[SND_ARR].ival = 0;
  3730. break;
  3731. case SND_REC: /* /RECURSIVE */
  3732. recursive = 2; /* Set the real variable */
  3733. pv[SND_PTH].ival = PATH_REL; /* Give them relative pathnames */
  3734. pv[n].ival = 1; /* Just set the flag */
  3735. break;
  3736. case SND_RES: /* /RECOVER (resend) */
  3737. pv[SND_ARR].ival = 0;
  3738. pv[SND_BIN].ival = 1; /* Implies /BINARY */
  3739. case SND_NOB: /* /NOBACKUP */
  3740. case SND_DEL: /* /DELETE */
  3741. case SND_SHH: /* /QUIET */
  3742. pv[n].ival = 1; /* Just set the flag */
  3743. break;
  3744. #ifdef UNIXOROSK
  3745. /* Like recursive, these are set immediately because they affect cmifi() */
  3746. case SND_DOT: /* /DOTFILES */
  3747. matchdot = 1;
  3748. break;
  3749. case SND_NOD: /* /NODOTFILES */
  3750. matchdot = 0;
  3751. break;
  3752. #endif /* UNIXOROSK */
  3753. /* File transfer modes - each undoes the others */
  3754. case SND_BIN: /* Binary */
  3755. case SND_TXT: /* Text */
  3756. case SND_IMG: /* Image */
  3757. case SND_LBL: /* Labeled */
  3758. pv[SND_BIN].ival = 0;
  3759. pv[SND_TXT].ival = 0;
  3760. pv[SND_IMG].ival = 0;
  3761. pv[SND_LBL].ival = 0;
  3762. pv[n].ival = 1;
  3763. break;
  3764. #ifdef CKSYMLINK
  3765. case SND_LNK:
  3766. case SND_NLK:
  3767. nolinks = (n == SND_NLK) ? 2 : 0;
  3768. cmfdbi(&sf, /* Redo cmifi() */
  3769. _CMIFI, /* fcode */
  3770. "File(s) to send", /* hlpmsg */
  3771. "", /* default */
  3772. "", /* addtl string data */
  3773. nolinks, /* addtl numeric data 1 */
  3774. 0, /* addtl numeric data 2 */
  3775. xxstring,
  3776. NULL,
  3777. mlist ? &cm : &fl
  3778. );
  3779. break;
  3780. #endif /* CKSYMLINK */
  3781. case SND_EXC: /* Excludes */
  3782. if (!getval) break;
  3783. if ((x = cmfld("Pattern","",&s,xxstring)) < 0) {
  3784. if (x == -3) {
  3785. printf("?Pattern required\n");
  3786. x = -9;
  3787. }
  3788. goto xsendx;
  3789. }
  3790. if (pv[n].sval) free(pv[n].sval);
  3791. y = strlen(s);
  3792. if (y > 256) {
  3793. printf("?Pattern too long - 256 max\n");
  3794. x = -9;
  3795. goto xsendx;
  3796. }
  3797. pv[n].sval = malloc(y+1);
  3798. if (pv[n].sval) {
  3799. strcpy(pv[n].sval,s); /* safe */
  3800. pv[n].ival = 1;
  3801. }
  3802. break;
  3803. case SND_MOV: /* MOVE after */
  3804. case SND_REN: /* RENAME after */
  3805. if (!getval) break;
  3806. if ((x = cmfld(n == SND_MOV ?
  3807. "device and/or directory for source file after sending" :
  3808. "new name for source file after sending",
  3809. "",
  3810. &s,
  3811. n == SND_MOV ? xxstring : NULL
  3812. )) < 0) {
  3813. if (x == -3) {
  3814. printf("%s\n", n == SND_MOV ?
  3815. "?Destination required" :
  3816. "?New name required"
  3817. );
  3818. x = -9;
  3819. }
  3820. goto xsendx;
  3821. }
  3822. if (pv[n].sval) free(pv[n].sval);
  3823. s = brstrip(s);
  3824. y = strlen(s);
  3825. if (y > 0) {
  3826. pv[n].sval = malloc(y+1);
  3827. if (pv[n].sval) {
  3828. strcpy(pv[n].sval,s); /* safe */
  3829. pv[n].ival = 1;
  3830. }
  3831. }
  3832. break;
  3833. case SND_SMA: /* Smaller / larger than */
  3834. case SND_LAR: {
  3835. CK_OFF_T w;
  3836. if (!getval) break;
  3837. if ((x = cmnumw("Size in bytes","0",10,&w,xxstring)) < 0)
  3838. goto xsendx;
  3839. pv[n].wval = w;
  3840. break;
  3841. }
  3842. case SND_AFT: /* Send /AFTER:date-time */
  3843. case SND_BEF: /* Send /BEFORE:date-time */
  3844. case SND_NAF: /* Send /NOT-AFTER:date-time */
  3845. case SND_NBE: /* Send /NOT-BEFORE:date-time */
  3846. if (!getval) break;
  3847. if ((x = cmdate("File date-time","",&s,0,xxstring)) < 0) {
  3848. if (x == -3) {
  3849. printf("?Date-time required\n");
  3850. x = -9;
  3851. }
  3852. goto xsendx;
  3853. }
  3854. if (pv[n].sval) free(pv[n].sval);
  3855. pv[n].sval = malloc((int)strlen(s)+1);
  3856. if (pv[n].sval) {
  3857. strcpy(pv[n].sval,s); /* safe */
  3858. pv[n].ival = 1;
  3859. }
  3860. break;
  3861. case SND_MAI: /* Send as mail (= MAIL) */
  3862. #ifdef IKSD
  3863. if (inserver && !ENABLED(en_mai)) {
  3864. printf("?Sorry, sending files as mail is disabled\n");
  3865. return(-9);
  3866. }
  3867. #endif /* IKSD */
  3868. pv[n].ival = 1;
  3869. if (!getval) break;
  3870. if ((x = cmfld("e-mail address","",&s,xxstring)) < 0) {
  3871. if (x == -3) {
  3872. printf("?address required\n");
  3873. x = -9;
  3874. }
  3875. goto xsendx;
  3876. }
  3877. s = brstrip(s);
  3878. if (pv[n].sval) free(pv[n].sval);
  3879. pv[n].sval = malloc((int)strlen(s)+1);
  3880. if (pv[n].sval)
  3881. strcpy(pv[n].sval,s); /* safe */
  3882. break;
  3883. case SND_PRI: /* Send to be printed (REMOTE PRINT) */
  3884. #ifdef IKSD
  3885. if (inserver && !ENABLED(en_mai)) {
  3886. printf("?Sorry, sending files for printing is disabled\n");
  3887. return(-9);
  3888. }
  3889. #endif /* IKSD */
  3890. pv[n].ival = 1;
  3891. if (!getval) break;
  3892. if ((x = cmfld("Print options","",&s,xxstring)) < 0)
  3893. if (x != -3) goto xsendx;
  3894. s = brstrip(s);
  3895. if (pv[n].sval) free(pv[n].sval);
  3896. pv[n].sval = malloc((int)strlen(s)+1);
  3897. if (pv[n].sval)
  3898. strcpy(pv[n].sval,s); /* safe */
  3899. break;
  3900. case SND_ASN: /* As-name */
  3901. debug(F101,"xsend /as-name getval","",getval);
  3902. if (!getval) break;
  3903. if ((x = cmfld("Name to send under","",&s,NULL)) < 0) {
  3904. if (x == -3) {
  3905. printf("?name required\n");
  3906. x = -9;
  3907. }
  3908. goto xsendx;
  3909. }
  3910. s = brstrip(s);
  3911. if ((y = strlen(s)) > 0) {
  3912. if (pv[n].sval) free(pv[n].sval);
  3913. pv[n].sval = malloc(y+1);
  3914. if (pv[n].sval) {
  3915. strcpy(pv[n].sval,s); /* safe */
  3916. pv[n].ival = 1;
  3917. }
  3918. }
  3919. break;
  3920. case SND_STA: { /* Starting position (= PSEND) */
  3921. CK_OFF_T w;
  3922. if (!getval) break;
  3923. if ((x = cmnumw("0-based position","0",10,&w,xxstring)) < 0)
  3924. goto xsendx;
  3925. pv[n].wval = w;
  3926. break;
  3927. }
  3928. case SND_PRO: /* Protocol to use */
  3929. if (!getval) break;
  3930. if ((x = cmkey(protos,nprotos,"File-transfer protocol","",
  3931. xxstring)) < 0) {
  3932. if (x == -3) {
  3933. printf("?name of protocol required\n");
  3934. x = -9;
  3935. }
  3936. goto xsendx;
  3937. }
  3938. pv[n].ival = x;
  3939. break;
  3940. #ifdef PIPESEND
  3941. case SND_FLT: /* Filter */
  3942. debug(F101,"xsend /filter getval","",getval);
  3943. if (!getval) break;
  3944. if ((x = cmfld("Filter program to send through","",&s,NULL)) < 0) {
  3945. if (x == -3)
  3946. s = "";
  3947. else
  3948. goto xsendx;
  3949. }
  3950. if (*s) s = brstrip(s);
  3951. y = strlen(s);
  3952. for (x = 0; x < y; x++) { /* Make sure they included "\v(...)" */
  3953. if (s[x] != '\\') continue;
  3954. if (s[x+1] == 'v') break;
  3955. }
  3956. if (x == y) {
  3957. printf(
  3958. "?Filter must contain a replacement variable for filename.\n"
  3959. );
  3960. x = -9;
  3961. goto xsendx;
  3962. }
  3963. pv[n].ival = 1;
  3964. if (pv[n].sval) {
  3965. free(pv[n].sval);
  3966. pv[n].sval = NULL;
  3967. }
  3968. if ((y = strlen(s)) > 0) {
  3969. if ((pv[n].sval = malloc(y+1)))
  3970. strcpy(pv[n].sval,s); /* safe */
  3971. }
  3972. break;
  3973. #endif /* PIPESEND */
  3974. case SND_PTH: /* Pathnames */
  3975. if (!getval) {
  3976. pv[n].ival = PATH_REL;
  3977. break;
  3978. }
  3979. if ((x = cmkey(pathtab,npathtab,"","absolute",xxstring)) < 0)
  3980. goto xsendx;
  3981. pv[n].ival = x;
  3982. break;
  3983. case SND_NAM: /* Filenames */
  3984. if (!getval) break;
  3985. if ((x = cmkey(fntab,nfntab,"","converted",xxstring)) < 0)
  3986. goto xsendx;
  3987. debug(F101,"xsend /filenames","",x);
  3988. pv[n].ival = x;
  3989. break;
  3990. #ifdef CALIBRATE
  3991. case SND_CAL: { /* /CALIBRATE */
  3992. CK_OFF_T w;
  3993. if (getval) {
  3994. if ((x = cmnumw("number of Kbytes to send",
  3995. "1024",10,&w,xxstring)) < 0)
  3996. goto xsendx;
  3997. } else
  3998. w = (CK_OFF_T)1024;
  3999. pv[n].wval = w;
  4000. pv[SND_ARR].ival = 0;
  4001. break;
  4002. }
  4003. #endif /* CALIBRATE */
  4004. case SND_FIL: /* Name of file containing filnames */
  4005. if (!getval) break;
  4006. if ((x = cmifi("Name of file containing list of filenames",
  4007. "",&s,&y,xxstring)) < 0) {
  4008. if (x == -3) {
  4009. printf("?Filename required\n");
  4010. x = -9;
  4011. }
  4012. goto xsendx;
  4013. } else if (y) {
  4014. printf("?Wildcards not allowed\n");
  4015. x = -9;
  4016. goto xsendx;
  4017. }
  4018. if (pv[n].sval)
  4019. free(pv[n].sval);
  4020. if (s) if (*s) {
  4021. if ((pv[n].sval = malloc((int)strlen(s)+1))) {
  4022. strcpy(pv[n].sval,s);
  4023. pv[n].ival = 1;
  4024. pv[SND_ARR].ival = 0;
  4025. }
  4026. }
  4027. break;
  4028. #ifndef NOSPL
  4029. case SND_ARR: /* SEND /ARRAY: */
  4030. if (!getval) break;
  4031. ap = NULL;
  4032. if ((x = cmfld("Array name (a single letter will do)",
  4033. "",
  4034. &s,
  4035. NULL
  4036. )) < 0) {
  4037. if (x == -3)
  4038. break;
  4039. else
  4040. return(x);
  4041. }
  4042. if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
  4043. printf("?Bad array: %s\n",s);
  4044. return(-9);
  4045. }
  4046. if (!(ap = a_ptr[x])) {
  4047. printf("?No such array: %s\n",s);
  4048. return(-9);
  4049. }
  4050. pv[n].ival = 1;
  4051. pv[SND_CMD].ival = 0; /* Undo any conflicting ones... */
  4052. pv[SND_RES].ival = 0;
  4053. pv[SND_CAL].ival = 0;
  4054. pv[SND_FIL].ival = 0;
  4055. arrayx = x;
  4056. break;
  4057. #endif /* NOSPL */
  4058. case SND_XPA: /* /TRANSPARENT */
  4059. pv[n].ival = 1;
  4060. break;
  4061. case SND_TYP: /* Only files of given type */
  4062. if (!getval) break;
  4063. if ((x = cmkey(txtbin,3,"","all",xxstring)) < 0)
  4064. goto xsendx;
  4065. pv[n].ival = (x == 2) ? -1 : x;
  4066. break;
  4067. default:
  4068. printf("?Unexpected switch value - %d\n",cmresult.nresult);
  4069. x = -9;
  4070. goto xsendx;
  4071. }
  4072. }
  4073. debug(F101,"xsend cmresult fcode","",cmresult.fcode);
  4074. #ifdef COMMENT
  4075. /* List switch parsing results in debug log */
  4076. for (i = 0; i <= SND_MAX; i++) {
  4077. ckmakmsg(line,LINBUFSIZ,"xsend switch ",ckitoa(i),NULL,NULL);
  4078. debug(F111,line, pv[i].sval, pv[i].ival);
  4079. }
  4080. #endif /* COMMENT */
  4081. /* Now we have all switches, plus maybe a filename or command, or nothing */
  4082. #ifdef PIPESEND
  4083. if (protocol != PROTO_K && pv[SND_CMD].ival > 0) {
  4084. printf("?Sorry, %s works only with Kermit protocol\n",
  4085. (cx == XXCSEN) ? "CSEND" : "SEND /COMMAND");
  4086. x = -9;
  4087. goto xsendx;
  4088. }
  4089. if (pv[SND_RES].ival > 0 || /* /RECOVER */
  4090. pv[SND_STA].wval > 0) { /* or /STARTING */
  4091. if (sndfilter || pv[SND_FLT].ival > 0) {
  4092. printf("?Sorry, no /RECOVER or /START if SEND FILTER selected\n");
  4093. x = -9;
  4094. goto xsendx;
  4095. }
  4096. }
  4097. #endif /* PIPESEND */
  4098. cmarg = "";
  4099. cmarg2 = "";
  4100. line[0] = NUL;
  4101. s = line;
  4102. wild = 0;
  4103. switch (cmresult.fcode) { /* How did we get out of switch loop */
  4104. case _CMIFI: /* Input filename */
  4105. ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* Name */
  4106. if (pv[SND_ARR].ival > 0)
  4107. cmarg2 = line;
  4108. else
  4109. wild = cmresult.nresult; /* Wild flag */
  4110. if (!recursive && !wild)
  4111. nolinks = 0;
  4112. break;
  4113. case _CMFLD: /* Field */
  4114. /* Only allowed with /COMMAND and /ARRAY */
  4115. if (pv[SND_CMD].ival < 1 && pv[SND_ARR].ival < 1) {
  4116. #ifdef CKROOT
  4117. if (ckrooterr)
  4118. printf("?Off limits: %s\n",cmresult.sresult);
  4119. else
  4120. #endif /* CKROOT */
  4121. printf("?%s - \"%s\"\n",
  4122. iswild(cmresult.sresult) ?
  4123. "No files match" : "File not found",
  4124. cmresult.sresult
  4125. );
  4126. x = -9;
  4127. goto xsendx;
  4128. }
  4129. ckstrncpy(line,cmresult.sresult,LINBUFSIZ);
  4130. if (pv[SND_ARR].ival > 0)
  4131. cmarg2 = line;
  4132. break;
  4133. case _CMCFM: /* Confirmation */
  4134. /* s = ""; */
  4135. confirmed = 1;
  4136. break;
  4137. default:
  4138. printf("?Unexpected function code: %d\n",cmresult.fcode);
  4139. x = -9;
  4140. goto xsendx;
  4141. }
  4142. debug(F110,"xsend string",s,0);
  4143. debug(F101,"xsend confirmed","",confirmed);
  4144. /* Save and change protocol and transfer mode */
  4145. /* Global values are restored in main parse loop */
  4146. g_proto = protocol; /* Save current global protocol */
  4147. g_urpsiz = urpsiz;
  4148. g_spsizf = spsizf;
  4149. g_spsiz = spsiz;
  4150. g_spsizr = spsizr;
  4151. g_spmax = spmax;
  4152. g_wslotr = wslotr;
  4153. g_prefixing = prefixing;
  4154. g_fncact = fncact;
  4155. g_fncnv = fncnv;
  4156. g_fnspath = fnspath;
  4157. g_fnrpath = fnrpath;
  4158. g_xfrxla = xfrxla;
  4159. if (pv[SND_PRO].ival > -1) { /* Change according to switch */
  4160. protocol = pv[SND_PRO].ival;
  4161. if (ptab[protocol].rpktlen > -1) /* copied from initproto() */
  4162. urpsiz = ptab[protocol].rpktlen;
  4163. if (ptab[protocol].spktflg > -1)
  4164. spsizf = ptab[protocol].spktflg;
  4165. if (ptab[protocol].spktlen > -1) {
  4166. spsiz = ptab[protocol].spktlen;
  4167. if (spsizf)
  4168. spsizr = spmax = spsiz;
  4169. }
  4170. if (ptab[protocol].winsize > -1)
  4171. wslotr = ptab[protocol].winsize;
  4172. if (ptab[protocol].prefix > -1)
  4173. prefixing = ptab[protocol].prefix;
  4174. if (ptab[protocol].fnca > -1)
  4175. fncact = ptab[protocol].fnca;
  4176. if (ptab[protocol].fncn > -1)
  4177. fncnv = ptab[protocol].fncn;
  4178. if (ptab[protocol].fnsp > -1)
  4179. fnspath = ptab[protocol].fnsp;
  4180. if (ptab[protocol].fnrp > -1)
  4181. fnrpath = ptab[protocol].fnrp;
  4182. }
  4183. debug(F101,"xsend protocol","",protocol);
  4184. if (pv[SND_NOB].ival > -1) { /* /NOBACKUP (skip backup file) */
  4185. g_skipbup = skipbup;
  4186. skipbup = 1;
  4187. }
  4188. if (pv[SND_REC].ival > 0) /* /RECURSIVE */
  4189. recursive = 2;
  4190. if (pv[SND_TYP].ival > -1) { /* /TYPE */
  4191. xfiletype = pv[SND_TYP].ival;
  4192. if (xfiletype == 2)
  4193. xfiletype = -1;
  4194. }
  4195. g_binary = binary; /* Save global transfer mode */
  4196. #ifdef PATTERNS
  4197. g_patterns = patterns; /* Save FILE PATTERNS setting */
  4198. #endif /* PATTERNS */
  4199. if (pv[SND_BIN].ival > 0) { /* Change according to switch */
  4200. /* If they said /BINARY they mean /BINARY */
  4201. patterns = 0; /* So no pattern-based switching */
  4202. g_xfermode = xfermode; /* or automatic transfer mode */
  4203. xfermode = XMODE_M;
  4204. binary = XYFT_B;
  4205. debug(F101,"doxsend /BINARY xfermode","",xfermode);
  4206. } else if (pv[SND_TXT].ival > 0) { /* Ditto for /TEXT */
  4207. patterns = 0;
  4208. g_xfermode = xfermode;
  4209. xfermode = XMODE_M;
  4210. binary = XYFT_T;
  4211. debug(F101,"doxsend /TEXT xfermode","",xfermode);
  4212. } else if (pv[SND_IMG].ival > 0) {
  4213. #ifdef VMS
  4214. binary = XYFT_I;
  4215. #else
  4216. binary = XYFT_B;
  4217. #endif /* VMS */
  4218. }
  4219. #ifdef CK_LABELED
  4220. else if (pv[SND_LBL].ival > 0) {
  4221. binary = XYFT_L;
  4222. }
  4223. #endif /* CK_LABELED */
  4224. debug(F101,"xsend binary","",binary);
  4225. if (pv[SND_XPA].ival > 0) /* /TRANSPARENT */
  4226. xfrxla = 0; /* Don't translate character sets */
  4227. /* Check for legal combinations of switches, filenames, etc */
  4228. #ifdef PIPESEND
  4229. if (pv[SND_CMD].ival > 0) { /* COMMAND - strip any braces */
  4230. debug(F110,"SEND /COMMAND before stripping",s,0);
  4231. s = brstrip(s);
  4232. debug(F110,"SEND /COMMAND after stripping",s,0);
  4233. if (!*s) {
  4234. printf("?Sorry, a command to send from is required\n");
  4235. x = -9;
  4236. goto xsendx;
  4237. }
  4238. cmarg = s;
  4239. }
  4240. #endif /* PIPESEND */
  4241. /* Set up /MOVE and /RENAME */
  4242. if (pv[SND_DEL].ival > 0 &&
  4243. (pv[SND_MOV].ival > 0 || pv[SND_REN].ival > 0)) {
  4244. printf("?Sorry, /DELETE conflicts with /MOVE or /RENAME\n");
  4245. x = -9;
  4246. goto xsendx;
  4247. }
  4248. #ifdef CK_TMPDIR
  4249. if (pv[SND_MOV].ival > 0) {
  4250. int len;
  4251. char * p = pv[SND_MOV].sval;
  4252. #ifdef CK_LOGIN
  4253. if (isguest) {
  4254. printf("?Sorry, /MOVE-TO not available to guests\n");
  4255. x = -9;
  4256. goto xsendx;
  4257. }
  4258. #endif /* CK_LOGIN */
  4259. len = strlen(p);
  4260. if (!isdir(p)) { /* Check directory */
  4261. #ifdef CK_MKDIR
  4262. char * s = NULL;
  4263. s = (char *)malloc(len + 4);
  4264. if (s) {
  4265. strcpy(s,p); /* safe */
  4266. #ifdef datageneral
  4267. if (s[len-1] != ':') { s[len++] = ':'; s[len] = NUL; }
  4268. #else
  4269. if (s[len-1] != '/') { s[len++] = '/'; s[len] = NUL; }
  4270. #endif /* datageneral */
  4271. s[len++] = 'X';
  4272. s[len] = NUL;
  4273. x = zmkdir(s);
  4274. free(s);
  4275. if (x < 0) {
  4276. printf("?Can't create \"%s\"\n",p);
  4277. x = -9;
  4278. goto xsendx;
  4279. }
  4280. }
  4281. #else
  4282. printf("?Directory \"%s\" not found\n",p);
  4283. x = -9;
  4284. goto xsendx;
  4285. #endif /* CK_MKDIR */
  4286. }
  4287. zfnqfp(p,LINBUFSIZ,tmpbuf);
  4288. makestr(&snd_move,tmpbuf);
  4289. }
  4290. #endif /* CK_TMPDIR */
  4291. if (pv[SND_REN].ival > 0) { /* /RENAME */
  4292. char * p = pv[SND_REN].sval;
  4293. #ifdef CK_LOGIN
  4294. if (isguest) {
  4295. printf("?Sorry, /RENAME-TO not available to guests\n");
  4296. x = -9;
  4297. goto xsendx;
  4298. }
  4299. #endif /* CK_LOGIN */
  4300. if (!p) p = "";
  4301. if (!*p) {
  4302. printf("?New name required for /RENAME\n");
  4303. x = -9;
  4304. goto xsendx;
  4305. }
  4306. p = brstrip(p);
  4307. #ifndef NOSPL
  4308. /* If name given is wild, rename string must contain variables */
  4309. if (wild) {
  4310. char * s = tmpbuf;
  4311. x = TMPBUFSIZ;
  4312. zzstring(p,&s,&x);
  4313. if (!strcmp(tmpbuf,p)) {
  4314. printf(
  4315. "?/RENAME for file group must contain variables such as \\v(filename)\n"
  4316. );
  4317. x = -9;
  4318. goto xsendx;
  4319. }
  4320. }
  4321. #endif /* NOSPL */
  4322. makestr(&snd_rename,p);
  4323. }
  4324. /* Handle /RECOVER and /START */
  4325. #ifdef CK_RESEND
  4326. if (pv[SND_RES].ival > 0 && binary != XYFT_B && !filepeek
  4327. #ifdef PATTERNS
  4328. && !patterns
  4329. #else
  4330. #ifdef VMS
  4331. /* VMS sets text/binary automatically later when it opens the file */
  4332. && 0
  4333. #endif /* VMS */
  4334. #endif /* PATTERNS */
  4335. ) {
  4336. printf("?Sorry, /BINARY required\n");
  4337. x = -9;
  4338. goto xsendx;
  4339. }
  4340. if (pv[SND_STA].wval > 0) { /* /START */
  4341. if (wild) {
  4342. printf("?Sorry, wildcards not permitted with /START\n");
  4343. x = -9;
  4344. goto xsendx;
  4345. }
  4346. if (sizeof(int) < 4) {
  4347. printf("?Sorry, this command needs at least 32-bit integers\n");
  4348. x = -9;
  4349. goto xsendx;
  4350. }
  4351. #ifdef CK_XYZ
  4352. if (protocol != PROTO_K) {
  4353. printf("?Sorry, SEND /START works only with Kermit protocol\n");
  4354. x = -9;
  4355. goto xsendx;
  4356. }
  4357. #endif /* CK_XYZ */
  4358. }
  4359. #ifdef CK_XYZ
  4360. if (pv[SND_RES].ival > 0) {
  4361. if (protocol != PROTO_K && protocol != PROTO_Z) {
  4362. printf(
  4363. "Sorry, /RECOVER is possible only with Kermit or ZMODEM protocol\n"
  4364. );
  4365. x = -9;
  4366. goto xsendx;
  4367. }
  4368. }
  4369. #endif /* CK_XYZ */
  4370. #endif /* CK_RESEND */
  4371. if (protocol == PROTO_K) {
  4372. if ((pv[SND_MAI].ival > 0 || /* MAIL */
  4373. pv[SND_PRI].ival > 0 || /* PRINT */
  4374. pv[SND_RES].ival > 0 /* RESEND */
  4375. ) &&
  4376. (!atdiso || !atcapr)) { /* Disposition attribute off? */
  4377. printf("?Sorry, ATTRIBUTE DISPOSITION must be ON\n");
  4378. x = -9;
  4379. goto xsendx;
  4380. }
  4381. }
  4382. #ifdef CK_XYZ
  4383. if (wild && (protocol == PROTO_X || protocol == PROTO_XC)) {
  4384. printf(
  4385. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  4386. );
  4387. x = -9;
  4388. goto xsendx;
  4389. }
  4390. #endif /* CK_XYZ */
  4391. if (!confirmed) { /* CR not typed yet, get more fields */
  4392. char *m;
  4393. if (mlist) { /* MSEND or MMOVE */
  4394. nfils = 0; /* We already have the first one */
  4395. #ifndef NOMSEND
  4396. msfiles[nfils++] = line; /* Store pointer */
  4397. lp = line + (int)strlen(line) + 1; /* Point past it */
  4398. debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4399. while (1) { /* Get more filenames */
  4400. char *p;
  4401. if ((x = cmifi("Names of files to send, separated by spaces",
  4402. "", &s,&y,xxstring)) < 0) {
  4403. if (x != -3)
  4404. goto xsendx;
  4405. if ((x = cmcfm()) < 0)
  4406. goto xsendx;
  4407. break;
  4408. }
  4409. msfiles[nfils++] = lp; /* Got one, count it, point to it, */
  4410. p = lp; /* remember pointer, */
  4411. while ((*lp++ = *s++)) /* and copy it into buffer */
  4412. if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  4413. printf("?MSEND list too long\n");
  4414. line[0] = NUL;
  4415. x = -9;
  4416. goto xsendx;
  4417. }
  4418. debug(F111,"xsend msend",msfiles[nfils-1],nfils-1);
  4419. if (nfils == 1) fspec[0] = NUL; /* Take care of \v(filespec) */
  4420. #ifdef ZFNQFP
  4421. zfnqfp(p,TMPBUFSIZ,tmpbuf);
  4422. p = tmpbuf;
  4423. #endif /* ZFNQFP */
  4424. if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  4425. strcat(fspec,p); /* safe */
  4426. strcat(fspec," "); /* safe */
  4427. } else
  4428. #ifdef COMMENT
  4429. printf("WARNING - \\v(filespec) buffer overflow\n");
  4430. #else
  4431. debug(F101,"doxsend filespec buffer overflow","",0);
  4432. #endif /* COMMENT */
  4433. }
  4434. #endif /* NOMSEND */
  4435. } else { /* Regular SEND */
  4436. char *p; int y;
  4437. nfils = -1;
  4438. if (pv[SND_MAI].ival > 0)
  4439. m = (pv[SND_MAI].sval) ?
  4440. "e-mail address (optional)" :
  4441. "e-mail address (required)";
  4442. else if (pv[SND_PRI].ival > 0)
  4443. m = "printer options (optional)";
  4444. else if (wild)
  4445. m =
  4446. "\nOptional as-name template containing replacement variables \
  4447. like \\v(filename)";
  4448. else
  4449. m = "Optional name to send it with";
  4450. if ((x = cmtxt(m,"",&p,NULL)) < 0)
  4451. goto xsendx;
  4452. if (!p) p = "";
  4453. if (*p) { /* If some text was given... */
  4454. p = brstrip(p); /* Replace /AS-NAME: value if any */
  4455. if ((y = strlen(p)) > 0) {
  4456. if (pv[SND_MAI].ival > 0) {
  4457. makestr(&pv[SND_MAI].sval, p);
  4458. } else {
  4459. if (pv[SND_ASN].sval) free(pv[SND_ASN].sval);
  4460. pv[SND_ASN].sval = malloc(y+1);
  4461. if (pv[SND_ASN].sval) {
  4462. strcpy(pv[SND_ASN].sval,p); /* safe */
  4463. pv[SND_ASN].ival = 1;
  4464. }
  4465. }
  4466. }
  4467. }
  4468. }
  4469. }
  4470. /* Set cmarg2 from as-name, however we got it. */
  4471. if (pv[SND_ASN].ival > 0 && pv[SND_ASN].sval && !*cmarg2) {
  4472. int x;
  4473. x = strlen(line);
  4474. ckstrncpy(line+x+2,pv[SND_ASN].sval,LINBUFSIZ-x-1);
  4475. cmarg2 = line+x+2;
  4476. debug(F110,"doxsend cmarg2",cmarg2,0);
  4477. }
  4478. #ifndef NOFRILLS
  4479. if ((pv[SND_MAI].ival > 0) && (pv[SND_PRI].ival > 0)) {
  4480. printf("Sorry, /MAIL and /PRINT are conflicting options\n");
  4481. x = -9;
  4482. goto xsendx;
  4483. }
  4484. n = 0; /* /MAIL or /PRINT? */
  4485. if (pv[SND_MAI].ival > 0)
  4486. n = SND_MAI;
  4487. else if (pv[SND_PRI].ival > 0)
  4488. n = SND_PRI;
  4489. if (n) { /* Yes... */
  4490. #ifdef DEBUG
  4491. char * p;
  4492. if (n == SND_MAI)
  4493. p = "/MAIL";
  4494. else
  4495. p = "/PRINT";
  4496. debug(F111,"xsend",p,n);
  4497. #endif /* DEBUG */
  4498. #ifdef CK_XYZ
  4499. if (protocol != PROTO_K) {
  4500. printf("Sorry, %s available only with Kermit protocol\n",
  4501. (n == SND_MAI) ? "/MAIL" : "/PRINT"
  4502. );
  4503. x = -9;
  4504. goto xsendx;
  4505. }
  4506. #endif /* CK_XYZ */
  4507. debug(F101,"xsend print/mail wild","",wild);
  4508. *optbuf = NUL; /* Wipe out any old options */
  4509. s = pv[n].sval; /* mail address or print switch val */
  4510. if (!s) s = "";
  4511. debug(F110,"doxsend mail address or printer options",s,0);
  4512. if (n == SND_MAI && !*s) {
  4513. printf("?E-mail address required\n");
  4514. x = -9;
  4515. goto xsendx;
  4516. } else if ((int)strlen(s) > 94) { /* Ensure legal size */
  4517. printf("?%s too long\n",
  4518. (n == SND_MAI) ?
  4519. "E-mail address" :
  4520. "Print option string"
  4521. );
  4522. x = -9;
  4523. goto xsendx;
  4524. }
  4525. ckstrncpy(optbuf,s,OPTBUFLEN); /* OK, copy to option buffer */
  4526. cmarg = line; /* File to send */
  4527. if (n == SND_MAI) {
  4528. debug(F110,"xsend mailing",cmarg,0);
  4529. debug(F110,"xsend address:",optbuf,0);
  4530. rmailf = 1;
  4531. } else {
  4532. debug(F110,"xsend printing",cmarg,0);
  4533. debug(F110,"xsend options",optbuf,0);
  4534. rprintf = 1;
  4535. }
  4536. }
  4537. #endif /* NOFRILLS */
  4538. #ifdef CALIBRATE
  4539. if (pv[SND_CAL].wval > 0) { /* Handle /CALIBRATE */
  4540. if (confirmed) {
  4541. calibrate = pv[SND_CAL].wval * (CK_OFF_T)1024;
  4542. sndsrc = -9;
  4543. nfils = 1;
  4544. wild = 0;
  4545. #ifndef NOMSEND
  4546. addlist = 0;
  4547. #endif /* NOMSEND */
  4548. ckstrncpy(line,"CALIBRATION",LINBUFSIZ);
  4549. s = cmarg = line;
  4550. if (!cmarg2) cmarg2 = "";
  4551. debug(F110,"doxsend cmarg2 calibrate",cmarg2,0);
  4552. } else if (line[0]) {
  4553. calibrate = 0;
  4554. pv[SND_CAL].ival = 0;
  4555. pv[SND_CAL].wval = 0;
  4556. }
  4557. }
  4558. #endif /* CALIBRATE */
  4559. if (pv[SND_FIL].ival > 0) {
  4560. if (confirmed && !calibrate) {
  4561. if (zopeni(ZMFILE,pv[SND_FIL].sval) < 1) {
  4562. debug(F110,"xsend can't open",pv[SND_FIL].sval,0);
  4563. printf("?Failure to open %s\n",filefile);
  4564. x = -9;
  4565. goto xsendx;
  4566. }
  4567. makestr(&filefile,pv[SND_FIL].sval); /* Open, remember name */
  4568. debug(F110,"xsend opened",filefile,0);
  4569. wild = 1;
  4570. }
  4571. }
  4572. /* SEND alone... */
  4573. #ifndef NOSPL
  4574. if (confirmed && pv[SND_ARR].ival > 0) {
  4575. if (!*cmarg2) {
  4576. sndxnam[7] = (char)((arrayx == 1) ? 64 : arrayx + ARRAYBASE);
  4577. cmarg2 = sndxnam;
  4578. }
  4579. cmarg = "";
  4580. goto sendend;
  4581. }
  4582. #endif /* NOSPL */
  4583. if (confirmed && !line[0] && !filefile && !calibrate) {
  4584. #ifndef NOMSEND
  4585. if (filehead) { /* OK if we have a SEND-LIST */
  4586. nfils = filesinlist;
  4587. sndsrc = nfils; /* Like MSEND */
  4588. addlist = 1; /* But using a different list... */
  4589. filenext = filehead;
  4590. goto sendend;
  4591. }
  4592. #endif /* NOMSEND */
  4593. printf("?Filename required but not given\n");
  4594. x = -9;
  4595. goto xsendx;
  4596. }
  4597. /* Not send-list or array */
  4598. #ifndef NOMSEND
  4599. addlist = 0; /* Don't use SEND-LIST. */
  4600. filenext = NULL;
  4601. #endif /* NOMSEND */
  4602. if (mlist) { /* MSEND or MMOVE */
  4603. #ifndef NOMSEND
  4604. cmlist = msfiles; /* List of files to send */
  4605. sndsrc = nfils;
  4606. cmarg2 = "";
  4607. sendstart = (CK_OFF_T)0;
  4608. #endif /* NOMSEND */
  4609. #ifdef PIPESEND
  4610. pipesend = 0;
  4611. #endif /* PIPESEND */
  4612. } else if (filefile) { /* File contains list of filenames */
  4613. s = "";
  4614. cmarg = "";
  4615. cmarg2 = "";
  4616. line[0] = NUL;
  4617. nfils = 1;
  4618. sndsrc = 1;
  4619. } else if (!calibrate && pv[SND_ARR].ival < 1 && pv[SND_CMD].ival < 1) {
  4620. nfils = sndsrc = -1; /* Not MSEND, MMOVE, /LIST, or /ARRAY */
  4621. if ( /* or /COMMAND */
  4622. #ifndef NOFRILLS
  4623. !rmailf && !rprintf /* Not MAIL or PRINT */
  4624. #else
  4625. 1
  4626. #endif /* NOFRILLS */
  4627. ) {
  4628. CK_OFF_T y = (CK_OFF_T)1;
  4629. if (!wild)
  4630. y = zchki(s);
  4631. if (y < (CK_OFF_T)0) {
  4632. printf("?Read access denied - \"%s\"\n", s);
  4633. x = -9;
  4634. goto xsendx;
  4635. }
  4636. if (s != line) /* We might already have done this. */
  4637. ckstrncpy(line,s,LINBUFSIZ); /* Copy of string just parsed. */
  4638. else
  4639. debug(F110,"doxsend line=s",line,0);
  4640. cmarg = line; /* File to send */
  4641. }
  4642. zfnqfp(cmarg,fspeclen,fspec);
  4643. }
  4644. if (!mlist) { /* For all but MSEND... */
  4645. #ifdef PIPESEND
  4646. if (pv[SND_CMD].ival > 0) /* /COMMAND sets pipesend flag */
  4647. pipesend = 1;
  4648. debug(F101,"xsend /COMMAND pipesend","",pipesend);
  4649. if (pipesend && filefile) {
  4650. printf("?Invalid switch combination\n");
  4651. x = -9;
  4652. goto xsendx;
  4653. }
  4654. #endif /* PIPESEND */
  4655. #ifndef NOSPL
  4656. /* If as-name given and filespec is wild, as-name must contain variables */
  4657. debug(F111,"doxsend cmarg2 wild",cmarg2,wild);
  4658. if (wild && *cmarg2) {
  4659. char * s = tmpbuf;
  4660. x = TMPBUFSIZ;
  4661. zzstring(cmarg2,&s,&x);
  4662. if (!strcmp(tmpbuf,cmarg2)) {
  4663. printf(
  4664. "?As-name for file group must contain variables such as \\v(filename)\n"
  4665. );
  4666. x = -9;
  4667. goto xsendx;
  4668. }
  4669. }
  4670. #endif /* NOSPL */
  4671. /* Strip braces from as-name */
  4672. debug(F110,"xsend cmarg2 before stripping",cmarg2,0);
  4673. cmarg2 = brstrip(cmarg2);
  4674. debug(F110,"xsend filename",cmarg,0);
  4675. debug(F110,"xsend as-name",cmarg2,0);
  4676. /* Copy as-name to a safe place */
  4677. if (asnbuf) {
  4678. free(asnbuf);
  4679. asnbuf = NULL;
  4680. }
  4681. if ((y = strlen(cmarg2)) > 0) {
  4682. asnbuf = (char *) malloc(y + 1);
  4683. if (asnbuf) {
  4684. strcpy(asnbuf,cmarg2); /* safe */
  4685. cmarg2 = asnbuf;
  4686. } else cmarg2 = "";
  4687. }
  4688. #ifdef CK_RESEND
  4689. debug(F111,"xsend pv[SND_STA].ival","",pv[SND_STA].ival);
  4690. if (pv[SND_STA].wval > (CK_OFF_T)-1) { /* /START position */
  4691. if (wild) {
  4692. printf("?/STARTING-AT may not be used with multiple files.\n");
  4693. x = -9;
  4694. goto xsendx;
  4695. } else
  4696. sendstart = pv[SND_STA].wval;
  4697. } else
  4698. sendstart = (CK_OFF_T)0;
  4699. debug(F101,"xsend /STARTING","",sendstart);
  4700. #endif /* CK_RESEND */
  4701. }
  4702. sendend: /* Common successful exit */
  4703. moving = 0;
  4704. if (pv[SND_SHH].ival > 0) { /* SEND /QUIET... */
  4705. g_displa = fdispla;
  4706. fdispla = 0;
  4707. debug(F101,"xsend display","",fdispla);
  4708. }
  4709. #ifndef NOSPL /* SEND /ARRAY... */
  4710. if (pv[SND_ARR].ival > 0) {
  4711. if (!ap) { x = -2; goto xsendx; } /* (shouldn't happen) */
  4712. if (range[0] == -1) /* If low end of range not specified */
  4713. range[0] = 1; /* default to 1 */
  4714. if (range[1] == -1) /* If high not specified */
  4715. range[1] = a_dim[arrayx]; /* default to size of array */
  4716. if ((range[0] < 0) || /* Check range */
  4717. (range[0] > a_dim[arrayx]) ||
  4718. (range[1] < range[0]) ||
  4719. (range[1] > a_dim[arrayx])) {
  4720. printf("?Bad array range - [%d:%d]\n",range[0],range[1]);
  4721. x = -9;
  4722. goto xsendx;
  4723. }
  4724. sndarray = ap; /* Array pointer */
  4725. sndxin = arrayx; /* Array index */
  4726. sndxlo = range[0]; /* Array range */
  4727. sndxhi = range[1];
  4728. sndxnam[7] = (char)((sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  4729. #ifdef COMMENT
  4730. printf("SENDING FROM ARRAY: &%c[]...\n", /* debugging */
  4731. (sndxin == 1) ? 64 : sndxin + ARRAYBASE);
  4732. printf("Lo=%d\nHi=%d\n", sndxlo, sndxhi);
  4733. printf("cmarg=[%s]\ncmarg2=[%s]\n", cmarg, cmarg2);
  4734. while ((x = agnbyte()) > -1) {
  4735. putchar((char)x);
  4736. }
  4737. return(1);
  4738. #endif /* COMMENT */
  4739. }
  4740. #endif /* NOSPL */
  4741. if (pv[SND_ARR].ival < 1) { /* File selection & disposition... */
  4742. if (pv[SND_DEL].ival > 0) /* /DELETE was specified */
  4743. moving = 1;
  4744. debug(F101,"xsend /DELETE","",moving);
  4745. if (pv[SND_AFT].ival > 0) /* Copy SEND criteria */
  4746. ckstrncpy(sndafter,pv[SND_AFT].sval,19);
  4747. if (pv[SND_BEF].ival > 0)
  4748. ckstrncpy(sndbefore,pv[SND_BEF].sval,19);
  4749. if (pv[SND_NAF].ival > 0)
  4750. ckstrncpy(sndnafter,pv[SND_NAF].sval,19);
  4751. if (pv[SND_NBE].ival > 0)
  4752. ckstrncpy(sndnbefore,pv[SND_NBE].sval,19);
  4753. if (pv[SND_EXC].ival > 0)
  4754. makelist(pv[SND_EXC].sval,sndexcept,NSNDEXCEPT);
  4755. if (pv[SND_SMA].wval > (CK_OFF_T)-1)
  4756. sndsmaller = pv[SND_SMA].wval;
  4757. if (pv[SND_LAR].wval > (CK_OFF_T)-1)
  4758. sndlarger = pv[SND_LAR].wval;
  4759. if (pv[SND_NAM].ival > -1) {
  4760. g_fncnv = fncnv; /* Save global value */
  4761. fncnv = pv[SND_NAM].ival;
  4762. debug(F101,"xsend fncnv","",fncnv);
  4763. }
  4764. if (pv[SND_PTH].ival > -1) {
  4765. g_spath = fnspath; /* Save global values */
  4766. fnspath = pv[SND_PTH].ival;
  4767. #ifndef NZLTOR
  4768. if (fnspath != PATH_OFF) {
  4769. g_fncnv = fncnv; /* Bad bad... */
  4770. fncnv = XYFN_C;
  4771. }
  4772. #endif /* NZLTOR */
  4773. debug(F101,"xsend fnspath","",fnspath);
  4774. debug(F101,"xsend fncnv","",fncnv);
  4775. }
  4776. }
  4777. #ifdef PIPESEND
  4778. if (pv[SND_FLT].ival > 0) {
  4779. makestr(&sndfilter,pv[SND_FLT].sval);
  4780. debug(F110,"xsend /FILTER", sndfilter, 0);
  4781. }
  4782. #endif /* PIPESEND */
  4783. #ifdef CK_APC
  4784. /* MOVE not allowed in APCs */
  4785. if (moving &&
  4786. (apcactive == APC_LOCAL || apcactive == APC_REMOTE)
  4787. && !(apcstatus & APC_UNCH))
  4788. return(success = 0);
  4789. #endif /* CK_APC */
  4790. #ifdef IKS_OPTION
  4791. if (
  4792. #ifdef CK_XYZ
  4793. protocol == PROTO_K &&
  4794. #endif /* CK_XYZ */
  4795. !iks_wait(KERMIT_REQ_START,1)) {
  4796. printf("?A Kermit Server is not available to process this command.\n");
  4797. printf("?Start a RECEIVE command to complement this command.\n");
  4798. }
  4799. #endif /* IKS_OPTION */
  4800. #ifdef IKSD
  4801. #ifdef CK_LOGIN
  4802. if (moving && inserver && isguest) {
  4803. printf("?File deletion not allowed for guests.\n");
  4804. return(-9);
  4805. }
  4806. #endif /* CK_LOGIN */
  4807. #endif /* IKSD */
  4808. sstate = 's'; /* Set start state to SEND */
  4809. sndcmd = 1;
  4810. #ifdef CK_RESEND
  4811. if (pv[SND_RES].ival > 0) /* Send sendmode appropriately */
  4812. sendmode = SM_RESEND;
  4813. else if (pv[SND_STA].ival > 0)
  4814. sendmode = SM_PSEND;
  4815. else
  4816. #endif /* CK_RESEND */
  4817. if (mlist)
  4818. sendmode = SM_MSEND;
  4819. else
  4820. sendmode = SM_SEND;
  4821. #ifdef MAC
  4822. what = W_SEND;
  4823. scrcreate();
  4824. #endif /* MAC */
  4825. if (local && pv[SND_SHH].ival != 0) { /* If in local mode, */
  4826. displa = 1; /* turn on file transfer display */
  4827. }
  4828. x = 0;
  4829. xsendx: /* Common exit, including failure */
  4830. debug(F101,"doxsend sndsrc","",sndsrc);
  4831. for (i = 0; i <= SND_MAX; i++) { /* Free malloc'd memory */
  4832. if (pv[i].sval)
  4833. free(pv[i].sval);
  4834. }
  4835. return(x);
  4836. }
  4837. #endif /* NOXFER */
  4838. #ifndef NOLOCAL
  4839. /* D O X C O N N -- CONNECT command parsing with switches */
  4840. #ifdef XLIMITS
  4841. #define XLIMORTRIGGER
  4842. #else
  4843. #ifdef CK_TRIGGER
  4844. #define XLIMORTRIGGER
  4845. #endif /* CK_TRIGGER */
  4846. #endif /* XLIMITS */
  4847. #ifdef CKTIDLE
  4848. int tt_idlelimit = 0; /* Terminal idle limit */
  4849. int tt_idleact = IDLE_RET; /* Terminal idle action */
  4850. #endif /* CKTIDLE */
  4851. #ifdef OS2 /* K95 only: */
  4852. extern int
  4853. tt_idlesnd_tmo; /* Idle interval */
  4854. int tt_timelimit = 0; /* Time limit, 0 = none */
  4855. extern char * /* Parse results - strings: */
  4856. tt_idlesnd_str; /* Idle string */
  4857. #endif /* OS2 */
  4858. #ifdef CK_TRIGGER
  4859. extern char *tt_trigger[];
  4860. extern CHAR *tt_trmatch[];
  4861. extern char *triggerval;
  4862. static char *g_tt_trigger[TRIGGERS];
  4863. #endif /* CK_TRIGGER */
  4864. #ifdef OS2
  4865. static int g_tt_idlesnd_tmo, g_tt_timelimit; /* For saving and restoring */
  4866. static int g_tt_idlelimit, g_tt_saved = 0;
  4867. static char * g_tt_idlesnd_str; /* global settings */
  4868. #endif /* OS2 */
  4869. static struct stringint pv[CONN_MAX+1];
  4870. VOID
  4871. resconn() {
  4872. int i;
  4873. #ifdef OS2
  4874. if ( g_tt_saved ) {
  4875. tt_idlelimit = g_tt_idlelimit;
  4876. tt_idlesnd_tmo = g_tt_idlesnd_tmo;
  4877. tt_timelimit = g_tt_timelimit;
  4878. tt_idlesnd_str = g_tt_idlesnd_str;
  4879. g_tt_saved = 0;
  4880. }
  4881. #endif /* OS2 */
  4882. #ifdef CK_TRIGGER
  4883. for (i = 0; i < TRIGGERS; i++)
  4884. tt_trigger[i] = g_tt_trigger[i];
  4885. #endif /* CK_TRIGGER */
  4886. for (i = 0; i <= CONN_MAX; i++) { /* Free malloc'd memory */
  4887. if (pv[i].sval)
  4888. free(pv[i].sval);
  4889. pv[i].sval = NULL;
  4890. }
  4891. }
  4892. int
  4893. doxconn(cx) int cx; {
  4894. int c, i, n; /* Workers */
  4895. int x, y;
  4896. int getval = 0; /* Whether to get switch value */
  4897. int async = 0; /* Make an async connect */
  4898. struct FDB sw, cm; /* FDBs for each parse function */
  4899. extern FILE * tfile[];
  4900. extern char * macp[];
  4901. #ifdef OS2
  4902. g_tt_idlesnd_tmo = tt_idlesnd_tmo; /* Save global settings */
  4903. g_tt_timelimit = tt_timelimit;
  4904. g_tt_idlelimit = tt_idlelimit;
  4905. g_tt_idlesnd_str = tt_idlesnd_str;
  4906. g_tt_saved = 1;
  4907. #endif /* OS2 */
  4908. #ifdef CK_TRIGGER
  4909. if (!tt_trigger[0]) { /* First initialization */
  4910. for (i = 1; i < TRIGGERS; i++)
  4911. tt_trigger[i] = NULL;
  4912. }
  4913. for (i = 0; i < TRIGGERS; i++)
  4914. g_tt_trigger[i] = tt_trigger[i];
  4915. if (triggerval) {
  4916. free(triggerval);
  4917. triggerval = NULL;
  4918. }
  4919. #endif /* CK_TRIGGER */
  4920. for (i = 0; i <= CONN_MAX; i++) { /* Initialize switch values */
  4921. pv[i].sval = NULL; /* to null pointers */
  4922. pv[i].ival = -1; /* and -1 int values */
  4923. pv[i].wval = (CK_OFF_T)-1;
  4924. }
  4925. if (cx == XXCQ) /* CQ == CONNECT /QUIETLY */
  4926. pv[CONN_NV].ival = 1;
  4927. /* Set up chained parse functions... */
  4928. cmfdbi(&sw, /* First FDB - command switches */
  4929. _CMKEY, /* fcode */
  4930. "Switch", /* hlpmsg */
  4931. "", /* default */
  4932. "", /* addtl string data */
  4933. nconntab, /* addtl numeric data 1: tbl size */
  4934. 4, /* addtl numeric data 2: 4 = cmswi */
  4935. xxstring, /* Processing function */
  4936. conntab, /* Keyword table */
  4937. &cm /* Pointer to next FDB */
  4938. );
  4939. cmfdbi(&cm, /* 2nd FDB - Confirmation */
  4940. _CMCFM, /* fcode */
  4941. "", /* hlpmsg */
  4942. "", /* default */
  4943. "", /* addtl string data */
  4944. 0, /* addtl numeric data 1 */
  4945. 0, /* addtl numeric data 2 */
  4946. NULL,
  4947. NULL,
  4948. NULL
  4949. );
  4950. while (1) { /* Parse 0 or more switches */
  4951. x = cmfdb(&sw); /* Parse switch or confirmation */
  4952. debug(F101,"doxconn cmfdb","",x);
  4953. if (x < 0) { /* Error */
  4954. if (x == -9 || x == -2)
  4955. printf("?No switches match - \"%s\"\n",atmbuf);
  4956. goto xconnx; /* or reparse needed */
  4957. }
  4958. if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
  4959. break;
  4960. c = cmgbrk(); /* Get break character */
  4961. getval = (c == ':' || c == '='); /* to see how they ended the switch */
  4962. if (getval && !(cmresult.kflags & CM_ARG)) {
  4963. printf("?This switch does not take arguments\n");
  4964. x = -9;
  4965. goto xconnx;
  4966. }
  4967. if (!getval && (cmgkwflgs() & CM_ARG)) {
  4968. printf("?This switch requires an argument\n");
  4969. return(-9);
  4970. }
  4971. n = cmresult.nresult; /* Numeric result = switch value */
  4972. debug(F101,"doxconn switch","",n);
  4973. switch (n) { /* Process the switch */
  4974. #ifdef OS2
  4975. case CONN_AS: /* Asynchronous */
  4976. pv[CONN_AS].ival = 1;
  4977. pv[CONN_SY].ival = 0;
  4978. break;
  4979. case CONN_SY: /* Synchronous */
  4980. pv[CONN_SY].ival = 1;
  4981. pv[CONN_AS].ival = 0;
  4982. break;
  4983. #endif /* OS2 */
  4984. case CONN_NV: /* Non-verbal */
  4985. pv[n].ival = 1;
  4986. break;
  4987. #ifdef XLIMITS
  4988. case CONN_II: /* Idle-interval */
  4989. case CONN_IL: /* Idle-limit */
  4990. case CONN_TL: /* Time-limit */
  4991. if (!getval) break;
  4992. if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
  4993. goto xconnx;
  4994. pv[n].ival = y;
  4995. break;
  4996. case CONN_IS: /* Idle-string */
  4997. #endif /* XLIMITS */
  4998. #ifdef CK_TRIGGER
  4999. case CONN_TS: /* Trigger-string */
  5000. #endif /* CK_TRIGGER */
  5001. #ifdef XLIMORTRIGGER
  5002. if (!getval) break;
  5003. if ((x = cmfld("String (enclose in braces if it contains spaces)",
  5004. "",&s,xxstring)) < 0) {
  5005. if (x == -3) {
  5006. printf("?String required\n");
  5007. x = -9;
  5008. }
  5009. goto xconnx;
  5010. }
  5011. if (n != CONN_TS)
  5012. s = brstrip(s);
  5013. if ((y = strlen(s)) > 0) {
  5014. if (pv[n].sval) free(pv[n].sval);
  5015. pv[n].sval = malloc(y+1);
  5016. if (pv[n].sval) {
  5017. strcpy(pv[n].sval,s); /* safe */
  5018. pv[n].ival = 1;
  5019. }
  5020. }
  5021. break;
  5022. #endif /* XLIMORTRIGGER */
  5023. default:
  5024. printf("?Unexpected switch value - %d\n",cmresult.nresult);
  5025. x = -9;
  5026. goto xconnx;
  5027. }
  5028. }
  5029. debug(F101,"doxconn cmresult.fcode","",cmresult.fcode);
  5030. if (cmresult.fcode != _CMCFM) {
  5031. printf("?Unexpected function code: %d\n",cmresult.fcode);
  5032. x = -9;
  5033. goto xconnx;
  5034. }
  5035. /* Command was confirmed so we can pre-pop command level. */
  5036. /* This is so CONNECT module won't think we're executing a script */
  5037. /* if CONNECT was the final command in the script. */
  5038. if (cmdlvl > 0)
  5039. prepop();
  5040. #ifdef OS2 /* Make results available globally */
  5041. if (pv[CONN_IL].ival > -1) /* Idle limit */
  5042. tt_idlelimit = pv[CONN_IL].ival;
  5043. if (pv[CONN_II].ival > -1) /* Idle limit */
  5044. tt_idlesnd_tmo = pv[CONN_II].ival;
  5045. if (pv[CONN_IS].sval) /* Idle string */
  5046. if (tt_idlesnd_str = (char *)malloc((int)strlen(pv[CONN_IS].sval)+1))
  5047. strcpy(tt_idlesnd_str,pv[CONN_IS].sval); /* safe */
  5048. if (pv[CONN_TL].ival > -1) /* Session limit */
  5049. tt_timelimit = pv[CONN_TL].ival;
  5050. async = (pv[CONN_AS].ival > 0 ||
  5051. pv[CONN_SY].ival <= 0 && cmdlvl == 0) ? 1 : 0;
  5052. #endif /* OS2 */
  5053. #ifdef CK_TRIGGER
  5054. if (pv[CONN_TS].sval) /* Trigger strings */
  5055. makelist(pv[CONN_TS].sval,tt_trigger,TRIGGERS);
  5056. for (i = 0; i < TRIGGERS; i++) /* Trigger match pointers */
  5057. tt_trmatch[i] = NULL;
  5058. if (triggerval) { /* Reset trigger value */
  5059. free(triggerval);
  5060. triggerval = NULL;
  5061. }
  5062. #endif /* CK_TRIGGER */
  5063. #ifdef SSHCMD
  5064. /*
  5065. 2010/03/01...
  5066. The previous connection was through the external ssh client and now, with
  5067. that connection closed, the user says "connect" and expects a new connection
  5068. to be made to the same host, because that's how all the other connection
  5069. methods work, so (and this is quite a hack)...
  5070. */
  5071. if (!ckstrcmp("ssh ",ttname,4,0)) { /* Previous "host" was "ssh blah" */
  5072. _PROTOTYP (int redossh, ( void ) );
  5073. extern int ttyfd;
  5074. if (ttyfd < 0) { /* And connection is no longer open */
  5075. int xx;
  5076. xx = redossh(); /* So redo the SSH connection */
  5077. if (xx < 0) return(xx);
  5078. goto xconnx;
  5079. }
  5080. }
  5081. #endif /* SSHCMD */
  5082. x = doconect((pv[CONN_NV].ival > 0) ? 1 : 0, async);
  5083. {
  5084. int xx;
  5085. debug(F101,"doxconn doconect returns","",x);
  5086. if ((xx = ttchk()) < 0) dologend();
  5087. debug(F101,"doxconn ttchk returns","",xx);
  5088. }
  5089. #ifdef CK_TRIGGER
  5090. debug(F111,"doxconn doconect triggerval",triggerval,x);
  5091. #endif /* CK_TRIGGER */
  5092. xconnx:
  5093. /* Back from CONNECT -- Restore global settings */
  5094. if (!async)
  5095. resconn();
  5096. success = (x > 0) ? 1 : 0;
  5097. return(x);
  5098. }
  5099. #endif /* NOLOCAL */
  5100. #ifdef ADDCMD
  5101. /* cx == XXADD or XXREMV */
  5102. /* fc == ADD_BIN or ADD_TXT */
  5103. static int
  5104. doadd(cx,fc) int cx, fc; {
  5105. #ifdef PATTERNS
  5106. char * tmp[FTPATTERNS];
  5107. char **p = NULL;
  5108. int i, j, k, n = 0, x = 0, last;
  5109. #endif /* PATTERNS */
  5110. if (cx != XXADD && cx != XXREMV) {
  5111. printf("?Unexpected function code: %d\n",cx);
  5112. return(-9);
  5113. }
  5114. #ifdef PATTERNS
  5115. while (n < FTPATTERNS) { /* Collect new patterns */
  5116. tmp[n] = NULL;
  5117. if ((x = cmfld("Pattern","",&s,xxstring)) < 0)
  5118. break;
  5119. ckstrncpy(line,s,LINBUFSIZ);
  5120. s = brstrip(line);
  5121. makestr(&(tmp[n++]),s);
  5122. }
  5123. if (x == -3)
  5124. x = cmcfm();
  5125. if (x < 0)
  5126. goto xdoadd;
  5127. p = (fc == ADD_BIN) ? binpatterns : txtpatterns; /* Which list */
  5128. last = 0;
  5129. for (i = 0; i < FTPATTERNS; i++) { /* Find last one in list */
  5130. if (!p[i]) {
  5131. last = i;
  5132. break;
  5133. }
  5134. }
  5135. if (cx == XXADD) { /* Adding */
  5136. if (last + n > FTPATTERNS) { /* Check if too many */
  5137. printf("?Too many patterns - %d is the maximum\n", FTPATTERNS);
  5138. goto xdoadd;
  5139. }
  5140. for (i = 0; i < n; i++) { /* Copy in the new ones. */
  5141. for (j = 0, x = 0; x == 0 && j < last ; j++ )
  5142. x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5143. if (x == 0)
  5144. makestr(&(p[last++]),tmp[i]);
  5145. }
  5146. makestr(&(p[last]),NULL); /* Null-terminate the list */
  5147. x = 1;
  5148. goto xdoadd; /* Done */
  5149. } else if (cx == XXREMV) { /* Remove something(s) */
  5150. int j, k;
  5151. if (last == 0) /* List is empty */
  5152. goto xdoadd; /* Nothing to remove */
  5153. for (i = 0; i < n; i++) { /* i = Patterns they typed */
  5154. for (j = 0; j < last; j++) { /* j = Patterns in list */
  5155. /* Change this to ckstrcmp()... */
  5156. if (filecase)
  5157. x = !ckstrcmp(tmp[i],p[j],-1,filecase); /* match */
  5158. else
  5159. x = ckstrcmp(tmp[i],p[j],-1,0); /* Case-independent match */
  5160. if (x) { /* This one matches */
  5161. makestr(&(p[j]),NULL); /* Free it */
  5162. for (k = j; k < last; k++) /* Move the rest up */
  5163. p[k] = p[k+1];
  5164. p[k] = NULL; /* Erase last one */
  5165. if (!p[k])
  5166. break;
  5167. }
  5168. }
  5169. }
  5170. }
  5171. xdoadd: /* Common exit */
  5172. for (i = 0; i < n; i++)
  5173. if (tmp[i])
  5174. free(tmp[i]);
  5175. return(x);
  5176. #endif /* PATTERNS */
  5177. }
  5178. /* ADD SEND-LIST */
  5179. static int
  5180. addsend(cx) int cx; {
  5181. #ifndef NOMSEND
  5182. extern struct keytab fttab[];
  5183. extern int nfttyp;
  5184. struct filelist * flp;
  5185. char * fmode = "";
  5186. int xmode = 0;
  5187. int xbinary = 0;
  5188. #endif /* NOMSEND */
  5189. #ifdef NOMSEND
  5190. printf("?Sorry, ADD/REMOVE SEND-LIST not available.\n");
  5191. return(-9);
  5192. #endif /* NOMSEND */
  5193. if (cx == XXREMV) {
  5194. printf("?Sorry, REMOVE SEND-LIST not implemented yet.\n");
  5195. return(-9);
  5196. }
  5197. #ifndef NOMSEND
  5198. #ifndef XYZ_INTERNAL
  5199. if (protocol != PROTO_K) {
  5200. printf("?Sorry, ADD SEND-LIST does not work with external protocols\n");
  5201. return(-9);
  5202. }
  5203. #endif /* XYZ_INTERNAL */
  5204. x = cmifi("File specification to add","", &s,&y,xxstring);
  5205. if (x < 0) {
  5206. if (x == -3) {
  5207. printf("?A file specification is required\n");
  5208. return(-9);
  5209. } else
  5210. return(x);
  5211. }
  5212. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5213. s = tmpbuf;
  5214. if (filesinlist == 0) /* Take care of \v(filespec) */
  5215. fspec[0] = NUL;
  5216. zfnqfp(s,LINBUFSIZ,line);
  5217. s = line;
  5218. if (((int)strlen(fspec) + (int)strlen(s) + 1) < fspeclen) {
  5219. strcat(fspec,s); /* safe */
  5220. strcat(fspec," "); /* safe */
  5221. } else
  5222. printf("WARNING - \\v(filespec) buffer overflow\n");
  5223. xbinary = binary;
  5224. if ((patterns || filepeek) /* FILE PATTERNS or SCAN is ON */
  5225. #ifdef CK_LABELED
  5226. && binary != XYFT_L /* And not if FILE TYPE LABELED */
  5227. #endif /* CK_LABELED */
  5228. #ifdef VMS
  5229. && binary != XYFT_I /* or FILE TYPE IMAGE */
  5230. #endif /* VMS */
  5231. ) {
  5232. int k, x;
  5233. x = -1;
  5234. k = scanfile(line,&x,nscanfile);
  5235. if (k > 0) xbinary = (k == FT_BIN) ? XYFT_B : XYFT_T;
  5236. }
  5237. fmode = gfmode(xbinary,0);
  5238. if ((x = cmkey(fttab,nfttyp,
  5239. "type of file transfer", fmode, xxstring)) < 0)
  5240. return(x);
  5241. xmode = x;
  5242. cmarg2 = "";
  5243. if ((x = cmfld(y ?
  5244. "\nAs-name template containing replacement variables such as \\v(filename)" :
  5245. "Name to send it with", "",&s,NULL)) < 0)
  5246. if (x != -3)
  5247. return(x);
  5248. #ifndef NOSPL
  5249. if (y && *s) {
  5250. char * p = tmpbuf;
  5251. x = TMPBUFSIZ;
  5252. zzstring(s,&p,&x);
  5253. if (!strcmp(tmpbuf,s)) {
  5254. printf(
  5255. "?As-name for file group must contain variables such as \\v(filename)\n"
  5256. );
  5257. return(-9);
  5258. }
  5259. }
  5260. #endif /* NOSPL */
  5261. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5262. cmarg2 = tmpbuf;
  5263. if ((x = cmcfm()) < 0)
  5264. return(x);
  5265. flp = (struct filelist *) malloc(sizeof(struct filelist));
  5266. if (flp) {
  5267. if (filetail)
  5268. filetail->fl_next = flp;
  5269. filetail = flp;
  5270. if (!filehead)
  5271. filehead = flp;
  5272. x = (int) strlen(line); /* Length of filename */
  5273. s = (char *) malloc(x + 1);
  5274. if (s) {
  5275. strcpy(s,line); /* safe */
  5276. flp->fl_name = s;
  5277. flp->fl_mode = xmode;
  5278. x = (int) strlen(cmarg2); /* Length of as-name */
  5279. if (x < 1) {
  5280. flp->fl_alias = NULL;
  5281. } else {
  5282. s = (char *) malloc(x + 1);
  5283. if (s) {
  5284. strcpy(s,cmarg2); /* safe */
  5285. flp->fl_alias = s;
  5286. } else {
  5287. printf("Sorry, can't allocate space for as-name");
  5288. return(-9);
  5289. }
  5290. }
  5291. flp->fl_next = NULL;
  5292. filesinlist++; /* Count this node */
  5293. return(success = 1); /* Finished adding this node */
  5294. } else {
  5295. printf("Sorry, can't allocate space for name");
  5296. return(-9);
  5297. }
  5298. } else {
  5299. printf("Sorry, can't allocate file list node");
  5300. return(-9);
  5301. }
  5302. #endif /* NOMSEND */
  5303. }
  5304. #endif /* ADDCMD */
  5305. #ifndef NOHTTP /* HTTP ops... */
  5306. #ifdef TCPSOCKET
  5307. #define HTTP_GET 0 /* GET */
  5308. #define HTTP_PUT 1 /* PUT */
  5309. #define HTTP_POS 2 /* POST */
  5310. #define HTTP_IDX 3 /* INDEX */
  5311. #define HTTP_HED 4 /* HEAD */
  5312. #define HTTP_DEL 5 /* DELETE */
  5313. #define HTTP_CON 6 /* CONNECT */
  5314. #define HTTP_OPN 7 /* OPEN */
  5315. #define HTTP_CLS 8 /* CLOSE */
  5316. static struct keytab httptab[] = {
  5317. { "close", HTTP_CLS, 0 },
  5318. { "connect", HTTP_CON, 0 },
  5319. { "delete", HTTP_DEL, 0 },
  5320. { "get", HTTP_GET, 0 },
  5321. { "head", HTTP_HED, 0 },
  5322. { "index", HTTP_IDX, 0 },
  5323. { "open", HTTP_OPN, 0 },
  5324. { "put", HTTP_PUT, 0 },
  5325. { "post", HTTP_POS, 0 }
  5326. };
  5327. static int nhttptab = sizeof(httptab)/sizeof(struct keytab);
  5328. /* HTTP switches */
  5329. #define HT_SW_AG 0 /* /AGENT */
  5330. #define HT_SW_HD 1 /* /HEADER */
  5331. #define HT_SW_US 2 /* /USER */
  5332. #define HT_SW_PW 3 /* /PASSWORD */
  5333. #define HT_SW_AR 4 /* /ARRAY */
  5334. #define HT_SW_TP 5 /* /TOSCREEN */
  5335. static struct keytab httpswtab[] = {
  5336. { "/agent", HT_SW_AG, CM_ARG },
  5337. #ifndef NOSPL
  5338. { "/array", HT_SW_AR, CM_ARG },
  5339. #endif /* NOSPL */
  5340. { "/header", HT_SW_HD, CM_ARG },
  5341. { "/password", HT_SW_PW, CM_ARG },
  5342. { "/toscreen", HT_SW_TP, 0 },
  5343. { "/user", HT_SW_US, CM_ARG },
  5344. { "", 0, 0 }
  5345. };
  5346. static int nhttpswtab = sizeof(httpswtab)/sizeof(struct keytab) - 1;
  5347. /* HTTP PUT/POST switches */
  5348. #define HT_PP_MT 0 /* /MIME-TYPE */
  5349. static struct keytab httpptab[] = {
  5350. { "/mime-type", HT_PP_MT, CM_ARG },
  5351. { "", 0, 0 }
  5352. };
  5353. static int nhttpptab = sizeof(httpptab)/sizeof(struct keytab) - 1;
  5354. #define HTTP_MAXHDR 8
  5355. static int
  5356. xdohttp(action, lfile, rf, dfile, agent, hdr, user, pass, mime, array, type)
  5357. int action;
  5358. char *lfile, *rf, *dfile, *agent, *hdr, *user, *pass, *mime, array;
  5359. int type;
  5360. /* xdohttp */ {
  5361. int i, rc = 0;
  5362. char * hdrlist[HTTP_MAXHDR];
  5363. char rfile[CKMAXPATH+1];
  5364. extern int httpfd;
  5365. /* Check for a valid state to execute the command */
  5366. if (inserver) {
  5367. printf("?The HTTP command may not be used from the IKS\r\n");
  5368. } else if (httpfd == -1) {
  5369. if (http_reopen() < 0)
  5370. printf("?No connection\n");
  5371. else
  5372. rc = 1;
  5373. } else {
  5374. rc = 1;
  5375. }
  5376. /* If the command is not valid, exit with failure */
  5377. if (rc == 0)
  5378. return(success = 0);
  5379. if (action != HTTP_CON && rf[0] != '/') {
  5380. rfile[0] = '/';
  5381. ckstrncpy(&rfile[1],rf,CKMAXPATH);
  5382. } else {
  5383. ckstrncpy(rfile,rf,CKMAXPATH);
  5384. }
  5385. for (i = 0; i < HTTP_MAXHDR; i++) /* Initialize header list */
  5386. hdrlist[i] = NULL;
  5387. makelist(hdr,hdrlist,HTTP_MAXHDR); /* Make header list */
  5388. #ifdef BETADEBUG
  5389. for (i = 0; i < nhttptab; i++) /* Find action keyword */
  5390. if (httptab[i].kwval == action)
  5391. break;
  5392. if (i == nhttptab) { /* Shouldn't happen... */
  5393. printf("?Invalid action - %d\n",action);
  5394. return(0); /* Failure */
  5395. }
  5396. printf("HTTP action: %s\n",httptab[i].kwd);
  5397. printf(" Agent: %s\n",agent ? agent : "(null)");
  5398. if (hdrlist[1]) {
  5399. printf(" Header list: 1. %s\n",hdrlist[0]);
  5400. for (i = 1; i < HTTP_MAXHDR && hdrlist[i]; i++)
  5401. printf("%15d. %s\n",i+1,hdrlist[i]);
  5402. } else
  5403. printf(" Header: %s\n",hdrlist[0] ? hdrlist[0] : "(null)");
  5404. printf(" User: %s\n",user ? user : "(null)");
  5405. #ifdef COMMENT
  5406. printf(" Password: %s\n",pass ? pass : "(null)");
  5407. #endif /* COMMENT */
  5408. #ifndef NOSPL
  5409. if (array)
  5410. printf(" Array: \\%%%c[]\n", array);
  5411. else
  5412. printf(" Array: (none)\n");
  5413. #endif /* NOSPL */
  5414. if (action == HTTP_PUT || action == HTTP_POS)
  5415. printf(" Mime-type: %s\n",mime ? mime : "(null)");
  5416. printf(" Local file: %s\n",lfile ? lfile : "(null)");
  5417. printf(" Remote file: %s\n",rfile ? rfile : "(null)");
  5418. printf(" Destination file: %s\n",dfile ? dfile : "(null)");
  5419. #endif /* BETADEBUG */
  5420. /* The http_xxxx() functions return 0 on success, -1 on failure */
  5421. switch (action) {
  5422. case HTTP_CON: {
  5423. extern int ttyfd;
  5424. rc = http_connect(httpfd,agent,hdrlist,user,pass,array,rfile);
  5425. break;
  5426. }
  5427. case HTTP_DEL:
  5428. rc = http_delete(agent,hdrlist,user,pass,array,rfile);
  5429. break;
  5430. case HTTP_GET:
  5431. rc = http_get(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5432. break;
  5433. case HTTP_HED:
  5434. rc = http_head(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5435. break;
  5436. case HTTP_PUT:
  5437. rc = http_put(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5438. type);
  5439. break;
  5440. case HTTP_POS:
  5441. rc = http_post(agent,hdrlist,mime,user,pass,array,lfile,rfile,dfile,
  5442. type);
  5443. break;
  5444. case HTTP_IDX:
  5445. rc = http_index(agent,hdrlist,user,pass,array,lfile,rfile,type);
  5446. break;
  5447. default:
  5448. rc = -1;
  5449. }
  5450. return(rc == 0 ? 1 : 0); /* Success is set by caller */
  5451. }
  5452. #endif /* TCPSOCKET */
  5453. #endif /* NOHTTP */
  5454. #ifndef NOSPL /* ARRAY ops... */
  5455. static struct keytab arraytab[] = {
  5456. { "clear", ARR_CLR, 0 },
  5457. { "copy", ARR_CPY, 0 },
  5458. { "dcl", ARR_DCL, CM_INV },
  5459. { "declare", ARR_DCL, 0 },
  5460. { "destroy", ARR_DST, CM_INV },
  5461. { "equate", ARR_EQU, CM_INV },
  5462. { "link", ARR_EQU, 0 },
  5463. { "resize", ARR_RSZ, 0 },
  5464. { "set", ARR_SET, 0 },
  5465. #ifndef NOSHOW
  5466. { "show", ARR_SHO, 0 },
  5467. #endif /* NOSHOW */
  5468. { "sort", ARR_SRT, 0 },
  5469. { "undeclare", ARR_DST, 0 },
  5470. { "", 0, 0 }
  5471. };
  5472. static int narraytab = sizeof(arraytab)/sizeof(struct keytab) - 1;
  5473. #ifdef CKLEARN
  5474. static struct keytab learnswi[] = {
  5475. { "/close", 2, 0 },
  5476. { "/off", 0, 0 },
  5477. { "/on", 1, 0 }
  5478. };
  5479. #endif /* CKLEARN */
  5480. int
  5481. arrayitoa(x) int x; { /* Array index to array letter */
  5482. if (x == 1)
  5483. return(64);
  5484. else if (x < 0 || x > (122 - ARRAYBASE))
  5485. return(-1);
  5486. else
  5487. return(x + ARRAYBASE);
  5488. }
  5489. int
  5490. arrayatoi(c) int c; { /* Array letter to array index */
  5491. if (c == 64)
  5492. c = 96;
  5493. if (c > 63 && c < 91)
  5494. c += 32;
  5495. if (c < ARRAYBASE || c > 122)
  5496. return(-1);
  5497. return(c - ARRAYBASE);
  5498. }
  5499. static int /* Declare an array */
  5500. dodcl(cx) int cx; {
  5501. int i, n, v, lo, hi, rc = 0;
  5502. int isdynamic = 0;
  5503. char tmpbuf[64];
  5504. char ** p = NULL;
  5505. char tmp[64]; /* Local temporary string buffer */
  5506. if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5507. if (y == -3) {
  5508. printf("?Array name required\n");
  5509. return(-9);
  5510. } else return(y);
  5511. }
  5512. ckstrncpy(line,s,LINBUFSIZ);
  5513. s = line;
  5514. x = arraybounds(s,&lo,&hi); /* Check syntax and get bounds */
  5515. debug(F111,"dodcl arraybounds",s,x);
  5516. if (x < 0) { /* Error - Maybe it's a variable */
  5517. char * p; /* whose value is an array name */
  5518. int n;
  5519. p = tmpbuf;
  5520. n = 63;
  5521. p[0] = NUL;
  5522. if (s[0] == CMDQ && s[1] == '&')
  5523. s++;
  5524. if (zzstring(s,&p,&n) > -1) {
  5525. s = tmpbuf;
  5526. x = arraybounds(s,&lo,&hi);
  5527. debug(F111,"dodcl arraybounds 2",s,x);
  5528. }
  5529. if (x < 0) {
  5530. printf("?Bad array name - \"%s\"\n",s);
  5531. return(-9);
  5532. }
  5533. }
  5534. debug(F101,"dodcl hi","",hi);
  5535. debug(F101,"dodcl lo","",lo);
  5536. debug(F101,"dodcl lo+1","",lo+1);
  5537. if (lo == -1 && hi == -1) { /* Have good array name and bounds */
  5538. isdynamic = 1;
  5539. n = CMDBL / 5;
  5540. } else if (hi > -1) {
  5541. printf("?Segment notation not allowed in array declarations\n");
  5542. return(-9);
  5543. } else if ((lo+1) < 0) {
  5544. debug(F101,"dodcl underflow","",lo+1);
  5545. printf("?Dimension underflow\n");
  5546. return(-9);
  5547. } else
  5548. n = lo;
  5549. x = arrayitoa(x);
  5550. if (cx == XXUNDCL) {
  5551. n = 0;
  5552. v = 0;
  5553. if ((y = cmcfm()) < 0)
  5554. return(y);
  5555. } else {
  5556. p = (char **)malloc(sizeof(char **)*(n+1));
  5557. if (!p) {
  5558. printf("?Memory allocation error\n");
  5559. return(-9);
  5560. }
  5561. v = 0; /* Highest initialized member */
  5562. p[0] = NULL; /* Element 0 */
  5563. keepallchars = 1;
  5564. while (n > 0 && v < n) { /* Parse initializers */
  5565. p[v+1] = NULL;
  5566. ckmakxmsg(tmp,
  5567. 64,
  5568. "Initial value for \\&",
  5569. ckctoa((char)x),
  5570. "[",
  5571. ckitoa(v+1),
  5572. "]",
  5573. NULL,NULL,NULL,NULL,NULL,NULL,NULL
  5574. );
  5575. rc = cmfld((char *)tmp,"",&s,xxstring); /* Get field */
  5576. if (rc < 0) { /* Error... */
  5577. if (rc == -3) { /* Empty element */
  5578. if (cmflgs == 1) /* because end of line? */
  5579. break; /* Yes, done initializing */
  5580. else /* No, it's just empty */
  5581. continue; /* Go on to next one. */
  5582. } else { /* Other parse error */
  5583. goto dclx; /* Go free temp pointers */
  5584. }
  5585. }
  5586. rc = 1;
  5587. if (v == 0 && !strcmp(s,"=")) /* Skip the = sign. */
  5588. continue;
  5589. s = brstrip(s); /* Strip any braces */
  5590. makestr(&(p[++v]),s);
  5591. }
  5592. keepallchars = 0;
  5593. if ((y = cmtxt("Carriage return to confirm","",&s,NULL)) < 0)
  5594. return(y);
  5595. if (isdynamic)
  5596. n = v;
  5597. }
  5598. if (dclarray((char)x,n) < 0) { /* Declare the array */
  5599. printf("?Declare failed\n");
  5600. goto dclx;
  5601. }
  5602. for (i = 1; i <= v; i++) { /* Add any initial values */
  5603. tmp[0] = '&';
  5604. ckmakmsg(&tmp[1],63,ckctoa((char)x),"[",ckitoa(i),"]");
  5605. if (addmac(tmp,p[i]) < 0) {
  5606. printf("Array initialization error: %s %s\n",tmp,p[i]);
  5607. rc = -9;
  5608. goto dclx;
  5609. }
  5610. }
  5611. dclx:
  5612. if (p) {
  5613. for (i = 1; i <= v; i++)
  5614. if (p[i]) free(p[i]);
  5615. free((char *)p);
  5616. }
  5617. debug(F101,"DCL rc","",rc);
  5618. return(success = rc);
  5619. }
  5620. static int
  5621. rszarray() {
  5622. int i, x, y, n, lo, hi, islink = -1;
  5623. char c, * s, ** ap = NULL;
  5624. if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5625. if (x == -3) {
  5626. printf("?Array name required\n");
  5627. return(-9);
  5628. } else return(x);
  5629. }
  5630. ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
  5631. s = line;
  5632. x = arraybounds(s,&lo,&hi);
  5633. if (x < 0) { /* Parse the name, get index */
  5634. printf("?Bad array reference - \"%s\"\n", s);
  5635. return(-9);
  5636. }
  5637. if (lo < 0 && hi < 0) {
  5638. y = cmnum("New size","",10,&lo,xxstring);
  5639. if (y < 0) {
  5640. if (y == -3)
  5641. printf("?New size required\n");
  5642. return(y);
  5643. }
  5644. }
  5645. if ((y = cmcfm()) < 0)
  5646. return(y);
  5647. if (a_link[x] > -1) { /* Link? */
  5648. islink = x; /* Yes follow it */
  5649. x = a_link[x]; /* and remember */
  5650. }
  5651. if (!a_ptr[x]) {
  5652. printf("?Array not declared - \"%s\"\n", s);
  5653. return(-9);
  5654. }
  5655. if (lo < 0) {
  5656. printf("?New size required\n");
  5657. return(-9);
  5658. }
  5659. if (hi > -1) {
  5660. printf("?Array segments not allowed for this operation\n");
  5661. return(-9);
  5662. }
  5663. c = arrayitoa(x); /* Get array letter */
  5664. if (c == '@') { /* Argument vector array off limits */
  5665. printf("?Sorry, \\&@[] is read-only\n");
  5666. return(-9);
  5667. }
  5668. if (lo == 0) { /* If new size is 0... */
  5669. dclarray(c,0); /* Undeclare the array */
  5670. return(success = 1);
  5671. }
  5672. n = a_dim[x]; /* Current size */
  5673. ap = (char **) malloc((lo+1) * sizeof(char *)); /* New array */
  5674. y = (n < lo) ? n : lo;
  5675. for (i = 0; i <= y; i++) /* Copy the part that fits */
  5676. ap[i] = a_ptr[x][i];
  5677. if (n < lo) { /* If original array smaller */
  5678. for (; i <= lo; i++) /* initialize extra elements in */
  5679. ap[i] = NULL; /* new array to NULL. */
  5680. } else if (n > lo) { /* If new array smaller */
  5681. for (; i <= lo; i++) /* deallocate leftover elements */
  5682. makestr(&(a_ptr[x][i]),NULL); /* from original array. */
  5683. }
  5684. free((char *)a_ptr[x]); /* Free original array list */
  5685. a_ptr[x] = ap; /* Replace with new one */
  5686. a_dim[x] = lo; /* Record the new dimension */
  5687. if (islink > -1) { /* Was this a link? */
  5688. a_ptr[islink] = ap; /* If so point to the resized array */
  5689. a_dim[islink] = lo;
  5690. } else { /* If not are there links to here? */
  5691. for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
  5692. if (i != x && a_link[i] == x) { /* Find and update them */
  5693. a_ptr[i] = ap;
  5694. a_dim[i] = lo;
  5695. }
  5696. }
  5697. }
  5698. return(success = 1);
  5699. }
  5700. static int
  5701. copyarray() {
  5702. int i, j, x1, lo1, hi1, x2, lo2, hi2, whole = 0;
  5703. char c1, c2, * a1, * a2;
  5704. if ((y = cmfld("Name of source array","",&s,NULL)) < 0)
  5705. return(y);
  5706. ckstrncpy(line,s,LINBUFSIZ);
  5707. a1 = line;
  5708. if ((x1 = arraybounds(a1,&lo1,&hi1)) < 0) {
  5709. printf("?Bad array reference - \"%s\"\n", a1);
  5710. return(-9);
  5711. } else if (!a_ptr[x1]) {
  5712. printf("?Array not declared - \"%s\"\n", a1);
  5713. return(-9);
  5714. }
  5715. c1 = arrayitoa(x1);
  5716. if ((y = cmfld("Name of destination array","",&s,NULL)) < 0)
  5717. return(y);
  5718. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  5719. a2 = tmpbuf;
  5720. if ((x2 = arraybounds(a2,&lo2,&hi2)) < 0) {
  5721. printf("?Bad array reference - \"%s\"\n", a2);
  5722. return(-9);
  5723. }
  5724. c2 = arrayitoa(x2);
  5725. if ((x = cmcfm()) < 0)
  5726. return(x);
  5727. if (c2 == '@') { /* Argument vector array off limits */
  5728. printf("?Sorry, \\&@[] is read-only\n");
  5729. return(-9);
  5730. }
  5731. if (lo1 < 0 && lo2 < 0 && hi1 < 0 && hi2 < 0) /* Special case for */
  5732. whole = 1; /* whole array... */
  5733. if (lo1 < 0) lo1 = whole ? 0 : 1; /* Supply lower bound of source */
  5734. if (hi1 < 0) hi1 = a_dim[x1]; /* Supply upper bound of source */
  5735. if (lo2 < 0) lo2 = whole ? 0 : 1; /* Lower bound of target */
  5736. if (hi2 < 0) hi2 = lo2 + hi1 - lo1; /* Upper bound of target */
  5737. if (a_ptr[x2]) { /* Target array is already declared? */
  5738. if (hi2 > a_dim[x2]) /* If upper bound out of range */
  5739. hi2 = a_dim[x2]; /* shrink to fit */
  5740. } else { /* Otherwise... */
  5741. x2 = dclarray(c2, hi2); /* declare the target array */
  5742. }
  5743. for (i = lo1, j = lo2; i <= hi1 && j <= hi2; i++,j++) { /* Copy */
  5744. makestr(&(a_ptr[x2][j]),a_ptr[x1][i]);
  5745. }
  5746. return(success = 1);
  5747. }
  5748. static int /* Undeclare an array */
  5749. unarray() {
  5750. int x, y, n, rc = 0;
  5751. char c, * s;
  5752. if ((y = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5753. if (y == -3) {
  5754. printf("?Array name required\n");
  5755. return(-9);
  5756. } else return(y);
  5757. }
  5758. ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
  5759. s = line;
  5760. if ((y = cmcfm()) < 0)
  5761. return(y);
  5762. if ((x = arraybounds(s,&y,&n)) < 0) { /* Parse the name, get index */
  5763. printf("?Bad array reference - \"%s\"\n", s);
  5764. return(-9);
  5765. }
  5766. if (y > 0 || n > 0) {
  5767. printf("?Partial arrays can not be destroyed\n");
  5768. return(-9);
  5769. }
  5770. c = arrayitoa(x); /* Get array letter */
  5771. if (a_ptr[x]) { /* If array is declared */
  5772. if (c == '@') { /* Argument vector array off limits */
  5773. printf("?Sorry, \\&@[] is read-only\n");
  5774. return(-9);
  5775. }
  5776. rc = dclarray(c,-1); /* Undeclare the array */
  5777. } else /* It wasn't declared */
  5778. rc = 1;
  5779. if (rc > -1) { /* Set return code and success */
  5780. success = 1;
  5781. rc = 1;
  5782. } else {
  5783. success = 0;
  5784. printf("?Failed - destroy \"\\&%c[]\"\n", c);
  5785. rc = -9;
  5786. }
  5787. return(rc);
  5788. }
  5789. static int
  5790. clrarray(cx) int cx; {
  5791. int i, x, lo, hi;
  5792. char c, * s, * val = NULL;
  5793. if ((x = cmfld("Array name","",&s,NULL)) < 0) { /* Parse array name */
  5794. if (x == -3) {
  5795. printf("?Array name required\n");
  5796. return(-9);
  5797. } else return(x);
  5798. }
  5799. ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of name */
  5800. s = line;
  5801. if (cx == ARR_SET) { /* SET */
  5802. if ((x = cmtxt("Value","",&val,xxstring)) < 0)
  5803. return(x);
  5804. ckstrncpy(tmpbuf,val,TMPBUFSIZ); /* Value to set */
  5805. val = tmpbuf;
  5806. if (!*val) val = NULL;
  5807. } else if ((x = cmcfm()) < 0) /* CLEAR */
  5808. return(x);
  5809. if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the name */
  5810. printf("?Bad array reference - \"%s\"\n", s);
  5811. return(-9);
  5812. }
  5813. c = arrayitoa(x); /* Get array letter */
  5814. if (!a_ptr[x]) { /* If array is declared */
  5815. printf("?Array %s is not declared\n", s);
  5816. return(-9);
  5817. } else if (c == '@') { /* Argument vector array off limits */
  5818. printf("?Sorry, \\&@[] is read-only\n");
  5819. return(-9);
  5820. }
  5821. if (lo < 0) lo = 0;
  5822. if (hi < 0) hi = a_dim[x];
  5823. for (i = lo; i <= hi; i++) /* Clear/Set selected range */
  5824. makestr(&(a_ptr[x][i]),val);
  5825. return(success = 1);
  5826. }
  5827. extern char **aa_ptr[CMDSTKL][28];
  5828. extern int aa_dim[CMDSTKL][28];
  5829. static int /* Create symbolic link to an array */
  5830. linkarray() {
  5831. int i = 0, x, y, lo, hi, flag = 0;
  5832. char c, * s, * p;
  5833. if ((x = cmfld("Array name not currently in use","",&s,NULL)) < 0) {
  5834. if (x == -3) {
  5835. printf("?Array name required\n");
  5836. return(-9);
  5837. } else return(x);
  5838. }
  5839. ckstrncpy(line,s,LINBUFSIZ); /* Make safe copy of link name */
  5840. s = line;
  5841. if ((x = cmfld("Name of existing array","",&p,xxstring)) < 0) {
  5842. if (x == -3) {
  5843. printf("?Array name required\n");
  5844. return(-9);
  5845. } else return(x);
  5846. }
  5847. ckstrncpy(tmpbuf,p,TMPBUFSIZ); /* Make safe copy of array name */
  5848. p = tmpbuf;
  5849. if ((x = cmcfm()) < 0)
  5850. return(x);
  5851. if ((x = arraybounds(s,&lo,&hi)) < 0) { /* Parse the link name */
  5852. printf("?Bad array reference - \"%s\"\n", s);
  5853. return(-9);
  5854. }
  5855. if (a_ptr[x]) { /* Must not already exist */
  5856. c = arrayitoa(x);
  5857. printf("?Array already exists: \\&%c[]\n", c);
  5858. return(-9);
  5859. }
  5860. if (lo > -1 || hi > -1) {
  5861. printf("?Sorry, whole arrays only: %s\n",s);
  5862. return(-9);
  5863. }
  5864. if ((y = arraybounds(p,&lo,&hi)) < 0) { /* Parse the array name */
  5865. printf("?Bad array reference - \"%s\"\n", s);
  5866. return(-9);
  5867. }
  5868. if (lo > -1 || hi > -1) {
  5869. printf("?Sorry, whole arrays only: %s\n",p);
  5870. return(-9);
  5871. }
  5872. if (x == y) {
  5873. for (i = cmdlvl; i >= 0; i--)
  5874. if (aa_ptr[i][x]) {
  5875. flag++;
  5876. break;
  5877. }
  5878. }
  5879. if (flag) {
  5880. a_ptr[x] = aa_ptr[i][y]; /* Link to saved copy */
  5881. a_dim[x] = aa_dim[i][y];
  5882. } else { /* Otherwise... */
  5883. c = arrayitoa(y); /* Check if it's declared */
  5884. if (!a_ptr[y]) {
  5885. printf("?Array is not declared: \\&%c[]\n", c);
  5886. return(-9);
  5887. }
  5888. if (a_link[y] > -1) { /* And if it's a link itself */
  5889. printf("?Links to links not allowed: \\&%c[]\n", c);
  5890. return(-9);
  5891. }
  5892. a_ptr[x] = a_ptr[y]; /* All OK, make the link */
  5893. a_dim[x] = a_dim[y];
  5894. }
  5895. a_link[x] = y;
  5896. return(success = 1);
  5897. }
  5898. #endif /* NOSPL */
  5899. #ifndef NOCSETS
  5900. static char * dcsetname = NULL;
  5901. /* Get Display Character-Set Name */
  5902. char *
  5903. getdcset() {
  5904. char * s;
  5905. int y;
  5906. #ifdef PCFONTS
  5907. extern int tt_font, ntermfont;
  5908. extern struct keytab term_font[];
  5909. #endif /* PCFONTS */
  5910. s = "";
  5911. #ifdef OS2
  5912. y = os2getcp(); /* Default is current code page */
  5913. switch (y) {
  5914. case 437: s = "cp437"; break;
  5915. case 850: s = "cp850"; break;
  5916. case 852: s = "cp852"; break;
  5917. case 857: s = "cp857"; break;
  5918. case 858: s = "cp858"; break;
  5919. case 862: s = "cp862"; break;
  5920. case 866: s = "cp866"; break;
  5921. case 869: s = "cp869"; break;
  5922. case 1250: s = "cp1250"; break;
  5923. case 1251: s = "cp1251"; break;
  5924. case 1252: s = "cp1252"; break;
  5925. case 1253: s = "cp1253"; break;
  5926. case 1254: s = "cp1254"; break;
  5927. case 1255: s = "cp1255"; break;
  5928. case 1256: s = "cp1256"; break;
  5929. case 1257: s = "cp1257"; break;
  5930. case 1258: s = "cp1258"; break;
  5931. }
  5932. #ifdef PCFONTS
  5933. /*
  5934. If the user has loaded a font with SET TERMINAL FONT then we want
  5935. to change the default code page to the font that was loaded.
  5936. */
  5937. if (tt_font != TTF_ROM) {
  5938. for (y = 0; y < ntermfont; y++ ) {
  5939. if (term_font[y].kwval == tt_font) {
  5940. s = term_font[y].kwd;
  5941. break;
  5942. }
  5943. }
  5944. }
  5945. #endif /* PCFONTS */
  5946. #else /* OS2 */
  5947. #ifdef COMMENT
  5948. /* Hack not needed as of C-Kermit 7.1 */
  5949. if (fcharset == FC_1LATIN) {
  5950. s = "latin1-iso"; /* Hack to avoid reporting "cp1252" */
  5951. } else { /* Report current file character set */
  5952. #endif /* COMMENT */
  5953. for (y = 0; y <= nfilc; y++)
  5954. if (fcstab[y].kwval == fcharset) {
  5955. s = fcstab[y].kwd;
  5956. break;
  5957. }
  5958. #ifdef COMMENT
  5959. }
  5960. #endif /* COMMENT */
  5961. #endif /* OS2 */
  5962. makestr(&dcsetname,s); /* Return stable pointer */
  5963. return((char *)dcsetname);
  5964. }
  5965. #endif /* NOCSETS */
  5966. #ifndef NOFRILLS
  5967. static int
  5968. doclear() {
  5969. if ((x = cmkey(clrtab,nclear,"item to clear",
  5970. #ifdef NOSPL
  5971. "device-buffer"
  5972. #else
  5973. "device-and-input"
  5974. #endif /* NOSPL */
  5975. ,xxstring)) < 0) return(x);
  5976. #ifndef NOSPL
  5977. #ifdef OS2
  5978. if (x == CLR_CMD || x == CLR_TRM) {
  5979. if ((z = cmkey(clrcmdtab,nclrcmd,"how much screen to clear\n",
  5980. "all",xxstring)) < 0)
  5981. return(z);
  5982. }
  5983. #endif /* OS2 */
  5984. #endif /* NOSPL */
  5985. if ((y = cmcfm()) < 0)
  5986. return(y);
  5987. /* Clear device input buffer if requested */
  5988. y = (x & CLR_DEV) ? ttflui() : 0;
  5989. if (x & CLR_SCR) /* CLEAR SCREEN */
  5990. y = ck_cls(); /* (= SCREEN CLEAR = CLS) */
  5991. if (x & CLR_KBD) { /* CLEAR KEYBOARD */
  5992. int n;
  5993. n = conchk();
  5994. y = 0;
  5995. while (n-- > 0 && (y = coninc(0) > -1))
  5996. ;
  5997. y = (y > -1) ? 0 : -1;
  5998. }
  5999. #ifndef NOSPL
  6000. /* Clear INPUT command buffer if requested */
  6001. if (x & CLR_INP) {
  6002. for (z = 0; z < inbufsize; z++)
  6003. inpbuf[z] = NUL;
  6004. inpbp = inpbuf;
  6005. y = 0;
  6006. }
  6007. #ifdef CK_APC
  6008. if (x & CLR_APC) {
  6009. debug(F101,"Executing CLEAR APC","",apcactive);
  6010. apcactive = 0;
  6011. y = 0;
  6012. }
  6013. #endif /* CK_APC */
  6014. if (x & CLR_ALR) {
  6015. setalarm(0L);
  6016. y = 0;
  6017. }
  6018. #endif /* NOSPL */
  6019. #ifdef PATTERNS
  6020. if (x & (CLR_TXT|CLR_BIN)) {
  6021. int i;
  6022. for (i = 0; i < FTPATTERNS; i++) {
  6023. if (x & CLR_TXT)
  6024. makestr(&txtpatterns[i],NULL);
  6025. if (x & CLR_BIN)
  6026. makestr(&binpatterns[i],NULL);
  6027. }
  6028. y = 0;
  6029. }
  6030. #endif /* PATTERNS */
  6031. #ifndef NODIAL
  6032. if (x & CLR_DIA) {
  6033. dialsta = DIA_UNK;
  6034. y = 0;
  6035. }
  6036. #endif /* NODIAL */
  6037. #ifndef NOMSEND
  6038. if (x & CLR_SFL) { /* CLEAR SEND-LIST */
  6039. if (filehead) {
  6040. struct filelist * flp, * next;
  6041. flp = filehead;
  6042. while (flp) {
  6043. if (flp->fl_name)
  6044. free(flp->fl_name);
  6045. if (flp->fl_alias)
  6046. free(flp->fl_alias);
  6047. next = flp->fl_next;
  6048. free((char *)flp);
  6049. flp = next;
  6050. }
  6051. }
  6052. filesinlist = 0;
  6053. filehead = NULL;
  6054. filetail = NULL;
  6055. addlist = 0;
  6056. y = 0;
  6057. }
  6058. #endif /* NOMSEND */
  6059. #ifdef OS2
  6060. #ifndef NOLOCAL
  6061. switch (x) {
  6062. case CLR_SCL:
  6063. clearscrollback(VTERM);
  6064. break;
  6065. case CLR_CMD:
  6066. switch ( z ) {
  6067. case CLR_C_ALL:
  6068. clear();
  6069. break;
  6070. case CLR_C_BOS:
  6071. clrboscr_escape(VCMD,SP);
  6072. break;
  6073. case CLR_C_BOL:
  6074. clrbol_escape(VCMD,SP);
  6075. break;
  6076. case CLR_C_EOL:
  6077. clrtoeoln(VCMD,SP);
  6078. break;
  6079. case CLR_C_EOS:
  6080. clreoscr_escape(VCMD,SP);
  6081. break;
  6082. case CLR_C_LIN:
  6083. clrline_escape(VCMD,SP);
  6084. break;
  6085. case CLR_C_SCR:
  6086. clearscrollback(VCMD);
  6087. break;
  6088. default:
  6089. printf("Not implemented yet, sorry.\n");
  6090. break;
  6091. }
  6092. break;
  6093. #ifndef NOTERM
  6094. case CLR_TRM:
  6095. switch ( z ) {
  6096. case CLR_C_ALL:
  6097. if (VscrnGetBufferSize(VTERM) > 0 ) {
  6098. VscrnScroll(VTERM, UPWARD, 0,
  6099. VscrnGetHeight(VTERM)-(tt_status[VTERM]?2:1),
  6100. VscrnGetHeight(VTERM) -
  6101. (tt_status[VTERM]?1:0), TRUE, SP
  6102. );
  6103. cleartermscreen(VTERM);
  6104. }
  6105. break;
  6106. case CLR_C_BOS:
  6107. clrboscr_escape(VTERM,SP);
  6108. break;
  6109. case CLR_C_BOL:
  6110. clrbol_escape(VTERM,SP);
  6111. break;
  6112. case CLR_C_EOL:
  6113. clrtoeoln(VTERM,SP);
  6114. break;
  6115. case CLR_C_EOS:
  6116. clreoscr_escape(VTERM,SP);
  6117. break;
  6118. case CLR_C_LIN:
  6119. clrline_escape(VTERM,SP);
  6120. break;
  6121. case CLR_C_SCR:
  6122. clearscrollback(VTERM);
  6123. break;
  6124. default:
  6125. printf("Not implemented yet, sorry.\n");
  6126. break;
  6127. }
  6128. break;
  6129. #endif /* NOTERM */
  6130. }
  6131. y = 0;
  6132. #endif /* NOLOCAL */
  6133. #endif /* OS2 */
  6134. return(success = (y == 0));
  6135. }
  6136. #endif /* NOFRILLS */
  6137. #ifndef NOSPL
  6138. static int
  6139. doeval(cx) int cx; {
  6140. char *p;
  6141. char vnambuf[VNAML], * vnp = NULL; /* These must be on the stack */
  6142. if (!oldeval) {
  6143. if ((y = cmfld("Variable name","",&s,
  6144. ((cx == XX_EVAL) ? xxstring : NULL))) < 0) {
  6145. if (y == -3) {
  6146. printf("?Variable name required\n");
  6147. return(-9);
  6148. } else return(y);
  6149. }
  6150. ckstrncpy(vnambuf,s,VNAML); /* Make a copy. */
  6151. vnp = vnambuf;
  6152. if (vnambuf[0] == CMDQ &&
  6153. (vnambuf[1] == '%' || vnambuf[1] == '&'))
  6154. vnp++;
  6155. y = 0;
  6156. if (*vnp == '%' || *vnp == '&') {
  6157. if ((y = parsevar(vnp,&x,&z)) < 0)
  6158. return(y);
  6159. }
  6160. }
  6161. if ((x = cmtxt("Integer arithmetic expression","",&s,xxstring)) < 0)
  6162. return(x);
  6163. p = evala(s);
  6164. if (!p) p = "";
  6165. if (oldeval && *p)
  6166. printf("%s\n", p);
  6167. ckstrncpy(evalbuf,p,32);
  6168. if (!oldeval)
  6169. return(success = addmac(vnambuf,p));
  6170. else
  6171. return(success = *p ? 1 : 0);
  6172. }
  6173. #endif /* NOSPL */
  6174. #ifdef TNCODE
  6175. static int
  6176. dotelopt() {
  6177. if ((x = cmkey(telcmd, ntelcmd, "TELNET command", "", xxstring)) < 0 )
  6178. return(x);
  6179. switch (x) {
  6180. case WILL:
  6181. case WONT:
  6182. case DO:
  6183. case DONT:
  6184. if ((y = cmkey(tnopts,ntnopts,"TELNET option","",xxstring)) < 0)
  6185. return(y);
  6186. if ((z = cmcfm()) < 0) return(z);
  6187. switch (x) {
  6188. case WILL:
  6189. if (TELOPT_UNANSWERED_WILL(y))
  6190. return(success = 0);
  6191. break;
  6192. case WONT:
  6193. if (TELOPT_UNANSWERED_WONT(y))
  6194. return(success = 0);
  6195. break;
  6196. case DO:
  6197. if (TELOPT_UNANSWERED_DO(y))
  6198. return(success = 0);
  6199. break;
  6200. case DONT:
  6201. if (TELOPT_UNANSWERED_DONT(y))
  6202. return(success = 0);
  6203. break;
  6204. }
  6205. if (local) {
  6206. success = ((tn_sopt(x,y) > -1) ? 1 : 0);
  6207. } else {
  6208. printf("ff%02x%02x\n",x,y);
  6209. success = 1;
  6210. }
  6211. if (success) {
  6212. switch (x) {
  6213. case WILL:
  6214. TELOPT_UNANSWERED_WILL(y) = 1;
  6215. break;
  6216. case WONT:
  6217. if ( TELOPT_ME(y) )
  6218. TELOPT_UNANSWERED_WONT(y) = 1;
  6219. break;
  6220. case DO:
  6221. TELOPT_UNANSWERED_DO(y) = 1;
  6222. break;
  6223. case DONT:
  6224. if ( TELOPT_ME(y) )
  6225. TELOPT_UNANSWERED_DONT(y) = 1;
  6226. break;
  6227. }
  6228. if (tn_wait("XXTELOP") < 0) {
  6229. tn_push();
  6230. success = 0;
  6231. }
  6232. }
  6233. return(success);
  6234. case SB:
  6235. if ((y=cmkey(tnsbopts,ntnsbopts,"TELNET option","",xxstring)) < 0)
  6236. return(y);
  6237. switch (y) {
  6238. case TELOPT_NAWS:
  6239. /* Some compilers require switch() to have at least 1 case */
  6240. #ifdef CK_NAWS
  6241. TELOPT_SB(TELOPT_NAWS).naws.x = 0;
  6242. TELOPT_SB(TELOPT_NAWS).naws.y = 0;
  6243. if (local)
  6244. return(success = ((tn_snaws() > -1) ? 1 : 0));
  6245. else
  6246. return(success = 0);
  6247. #else
  6248. return(success = 0);
  6249. #endif /* CK_NAWS */
  6250. }
  6251. return(success = 0);
  6252. #ifdef CK_KERBEROS
  6253. #ifdef KRB5
  6254. case TN_FWD:
  6255. success = (kerberos5_forward() == AUTH_SUCCESS);
  6256. return(success);
  6257. #endif /* KRB5 */
  6258. #endif /* CK_KERBEROS */
  6259. default:
  6260. if ((z = cmcfm()) < 0) return(z);
  6261. #ifndef NOLOCAL
  6262. if (local) {
  6263. CHAR temp[3];
  6264. if (network && IS_TELNET()) { /* TELNET */
  6265. temp[0] = (CHAR) IAC;
  6266. temp[1] = x;
  6267. temp[2] = NUL;
  6268. success = (ttol((CHAR *)temp,2) > -1 ? 1 : 0);
  6269. if (tn_deb || debses || deblog) {
  6270. /* TN_MSG_LEN is in ckctel.h */
  6271. ckmakmsg(tn_msg,256,"TELNET SENT ",TELCMD(x),NULL,NULL);
  6272. debug(F101,tn_msg,"",x);
  6273. if (debses || tn_deb) tn_debug(tn_msg);
  6274. }
  6275. return(success);
  6276. }
  6277. return(success = 0);
  6278. } else {
  6279. #endif /* NOLOCAL */
  6280. printf("ff%02x\n",x);
  6281. return(success = 1);
  6282. #ifndef NOLOCAL
  6283. }
  6284. #endif /* NOLOCAL */
  6285. }
  6286. }
  6287. #endif /* TNCODE */
  6288. #ifndef NOPUSH
  6289. #ifndef NOFRILLS
  6290. static int
  6291. doedit() {
  6292. #ifdef OS2
  6293. char * p = NULL;
  6294. #endif /* OS2 */
  6295. if (!editor[0]) {
  6296. s = getenv("EDITOR");
  6297. if (s) ckstrncpy(editor,s,CKMAXPATH);
  6298. editor[CKMAXPATH] = NUL;
  6299. if (!editor[0]) {
  6300. printf("?Editor not defined - use SET EDITOR to define\n");
  6301. return(-9);
  6302. }
  6303. }
  6304. ckstrncpy(tmpbuf,editfile,TMPBUFSIZ);
  6305. /*
  6306. cmiofi() lets us parse the name of an existing file, or the name of
  6307. a nonexistent file to be created.
  6308. */
  6309. x = cmiofi("File to edit", (char *)tmpbuf, &s, &y, xxstring);
  6310. debug(F111,"edit",s,x);
  6311. if (x < 0 && x != -3)
  6312. return(x);
  6313. if (x == -3) {
  6314. tmpbuf[0] = NUL;
  6315. } else {
  6316. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  6317. }
  6318. if ((z = cmcfm()) < 0) return(z);
  6319. if (y) {
  6320. printf("?A single file please\n");
  6321. return(-9);
  6322. }
  6323. if (nopush) {
  6324. printf("?Sorry, editing not allowed\n");
  6325. return(success = 0);
  6326. }
  6327. if (tmpbuf[0]) {
  6328. /* Get full path in case we change directories between EDIT commands */
  6329. zfnqfp(tmpbuf, CKMAXPATH, editfile);
  6330. editfile[CKMAXPATH] = NUL;
  6331. #ifdef OS2
  6332. p = editfile; /* Flip the stupid slashes */
  6333. while (*p) {
  6334. if (*p == '/') *p = '\\';
  6335. p++;
  6336. }
  6337. #endif /* OS2 */
  6338. } else
  6339. editfile[0] = NUL;
  6340. if (editfile[0]) {
  6341. if (zchki(editfile) < (CK_OFF_T)0 && zchko(editfile) < 0) {
  6342. printf("?Access denied: %s\n",editfile);
  6343. return(-9);
  6344. }
  6345. }
  6346. x = 0;
  6347. if (editopts[0]) {
  6348. #ifdef OS2
  6349. x = ckindex("%1",(char *)editopts,0,0,1);
  6350. if (x > 0)
  6351. editopts[x] = 's';
  6352. else
  6353. #endif /* OS2 */
  6354. x = ckindex("%s",(char *)editopts,0,0,1);
  6355. }
  6356. if (((int)strlen(editopts) + (int)strlen(editfile) + 1) < TMPBUFSIZ) {
  6357. if (x)
  6358. sprintf(tmpbuf,editopts,editfile);
  6359. else
  6360. sprintf(tmpbuf,"%s %s",editopts,editfile);
  6361. }
  6362. s = line;
  6363. ckmakmsg(s,LINBUFSIZ,editor," ",tmpbuf,NULL);
  6364. #ifdef OS2
  6365. p = s + strlen(editor); /* And again with the slashes */
  6366. while (p != s) {
  6367. if (*p == '/') *p = '\\';
  6368. p--;
  6369. }
  6370. #endif /* OS2 */
  6371. conres();
  6372. x = zshcmd(s);
  6373. concb((char)escape);
  6374. return(x);
  6375. }
  6376. #endif /* NOFRILLS */
  6377. #endif /* NOPUSH */
  6378. #ifdef BROWSER
  6379. static int
  6380. dobrowse() {
  6381. #ifdef OS2
  6382. char * p = NULL;
  6383. #endif /* OS2 */
  6384. if (nopush) {
  6385. printf("?Sorry, browsing not allowed\n");
  6386. return(success = 0);
  6387. }
  6388. #ifndef NT
  6389. /* Windows lets the Shell Execute the URL if no Browser is defined */
  6390. if (!browser[0]) {
  6391. s = getenv("BROWSER");
  6392. if (s) ckstrncpy(browser,s,CKMAXPATH);
  6393. browser[CKMAXPATH] = NUL;
  6394. if (!browser[0]) {
  6395. printf("?Browser not defined - use SET BROWSER to define\n");
  6396. return(-9);
  6397. }
  6398. }
  6399. #endif /* NT */
  6400. ckstrncpy(tmpbuf,browsurl,TMPBUFSIZ);
  6401. if ((x = cmtxt("URL",(char *)browsurl,&s,xxstring)) < 0)
  6402. return(x);
  6403. ckstrncpy(browsurl,s,4096);
  6404. x = 0;
  6405. if (browsopts[0]) {
  6406. #ifdef OS2
  6407. x = ckindex("%1",(char *)browsopts,0,0,1);
  6408. if (x > 0)
  6409. browsopts[x] = 's';
  6410. else
  6411. #endif /* OS2 */
  6412. x = ckindex("%s",(char *)browsopts,0,0,1);
  6413. }
  6414. if (((int)strlen(browsopts) + (int)strlen(browsurl) + 1) < TMPBUFSIZ) {
  6415. if (x)
  6416. sprintf(tmpbuf,browsopts,browsurl);
  6417. else
  6418. sprintf(tmpbuf,"%s %s",browsopts,browsurl);
  6419. }
  6420. #ifdef NT
  6421. if (!browser[0])
  6422. return(success = Win32ShellExecute(browsurl));
  6423. #endif /* NT */
  6424. s = line;
  6425. ckmakmsg(s,LINBUFSIZ,browser," ",tmpbuf,NULL);
  6426. #ifdef OS2
  6427. p = line + strlen(browser); /* Flip slashes */
  6428. while (p != line) {
  6429. if (*p == '/') *p = '\\';
  6430. p--;
  6431. }
  6432. #endif /* OS2 */
  6433. conres();
  6434. x = zshcmd(s);
  6435. concb((char)escape);
  6436. return(x);
  6437. }
  6438. #endif /* BROWSER */
  6439. #ifdef CK_RECALL
  6440. static int
  6441. doredo() { /* Find a previous cmd and redo it */
  6442. extern int on_recall, in_recall;
  6443. int x;
  6444. char * p;
  6445. if ((x = cmtxt(
  6446. "pattern, or first few characters of a previous command",
  6447. "*",&s,xxstring)) < 0)
  6448. return(x);
  6449. ckstrncpy(line,s,LINBUFSIZ);
  6450. x = strlen(s);
  6451. s = line;
  6452. if (*s == '{') { /* Braces disable adding * to end */
  6453. if (s[x-1] == '}') {
  6454. s[x-1] = NUL;
  6455. s++;
  6456. x--;
  6457. }
  6458. } else { /* No braces, add * to end. */
  6459. s[x] = '*';
  6460. s[x+1] = NUL;
  6461. }
  6462. while (x > 0 && s[x] == '*' && s[x-1] == '*') s[x--] = NUL;
  6463. if (!on_recall || !in_recall) {
  6464. printf("?Sorry, command recall can't be used now.\n");
  6465. return(-9);
  6466. }
  6467. if ((p = cmgetcmd(s))) { /* Look for it history buffer */
  6468. ckmakmsg(cmdbuf,CMDBL,p,"\r",NULL,NULL); /* Copy to command buffer */
  6469. if (!quiet) /* Echo it */
  6470. printf("%s\n",cmdbuf);
  6471. cmaddnext(); /* Force re-add to history buffer */
  6472. return(cmflgs = -1); /* Force reparse */
  6473. } else {
  6474. printf("?Sorry - \"%s\" not found\n", s);
  6475. return(-9);
  6476. }
  6477. }
  6478. #endif /* CK_RECALL */
  6479. #ifndef NOXFER
  6480. #ifndef NOCSETS
  6481. static int
  6482. doassoc() { /* ASSOCIATE */
  6483. extern struct keytab tcstab[];
  6484. extern int ntcs;
  6485. if ((x = cmkey(assoctab, nassoc, "", "", xxstring)) < 0 )
  6486. return(x);
  6487. switch (x) { /* Associate what? */
  6488. case ASSOC_TC: /* Transfer character-set... */
  6489. if ((x = cmkey(tcstab, ntcs,
  6490. "transfer character-set name","",xxstring)) < 0)
  6491. return(x);
  6492. if ((y = cmkey(fcstab, nfilc,
  6493. "with file character-set","", xxstring)) < 0)
  6494. if (y != -3)
  6495. return(y);
  6496. if ((z = cmcfm()) < 0)
  6497. return(z);
  6498. axcset[x] = y;
  6499. return(success = 1);
  6500. case ASSOC_FC: /* File character-set... */
  6501. if ((x = cmkey(fcstab, nfilc,
  6502. "file character-set name","",xxstring)) < 0)
  6503. return(x);
  6504. if ((y = cmkey(tcstab, ntcs,
  6505. "with transfer character-set","", xxstring)) < 0)
  6506. if (y != -3)
  6507. return(y);
  6508. if ((z = cmcfm()) < 0)
  6509. return(z);
  6510. afcset[x] = y;
  6511. return(success = 1);
  6512. default:
  6513. return(-2);
  6514. }
  6515. }
  6516. #endif /* NOCSETS */
  6517. #endif /* NOXFER */
  6518. #ifndef NOHELP
  6519. static int
  6520. domanual() {
  6521. #ifdef OS2
  6522. if ((x = cmcfm()) < 0)
  6523. return(x);
  6524. if (nopush) {
  6525. printf("?Sorry, access to system commands is disabled.\n");
  6526. return(-9);
  6527. }
  6528. y = mxlook(mactab,"manual",nmac);
  6529. if (y > -1) {
  6530. z = maclvl; /* Save the current maclvl */
  6531. dodo(y,NULL,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  6532. while (maclvl > z) {
  6533. debug(F101,"XXMAN loop maclvl 1","",maclvl);
  6534. sstate = (CHAR) parser(1);
  6535. debug(F101,"XXMAN loop maclvl 2","",maclvl);
  6536. if (sstate) proto();
  6537. }
  6538. debug(F101,"XXMAN loop exit maclvl","",maclvl);
  6539. return(success);
  6540. }
  6541. return(success = 0);
  6542. #else
  6543. if ((x = cmtxt(
  6544. #ifdef UNIX
  6545. "Carriage return to confirm the command, or manual topic",
  6546. #else
  6547. "Carriage return to confirm the command, or help topic",
  6548. #endif /* UNIX */
  6549. "kermit",
  6550. &s,
  6551. xxstring
  6552. )
  6553. ) < 0)
  6554. return(x);
  6555. #endif /* OS2 */
  6556. #ifdef UNIX
  6557. ckmakmsg(tmpbuf,TMPBUFSIZ,"man ",s,NULL,NULL);
  6558. #else
  6559. ckmakmsg(tmpbuf,TMPBUFSIZ,"help ",s,NULL,NULL);
  6560. #endif /* UNIX */
  6561. debug(F110,"MANUAL",tmpbuf,0);
  6562. if (nopush) {
  6563. printf("?Sorry, access to system commands is disabled.\n");
  6564. return(-9);
  6565. } else {
  6566. conres(); /* Restore the console */
  6567. success = zshcmd(tmpbuf);
  6568. concb((char)escape); /* Restore CBREAK mode */
  6569. return(success);
  6570. }
  6571. }
  6572. #endif /* NOHELP */
  6573. #ifndef NOHTTP
  6574. #ifdef TCPSOCKET
  6575. static struct keytab sslswtab[] = {
  6576. { "/ssl", 1, 0 },
  6577. { "/tls", 1, 0 }
  6578. };
  6579. #ifndef NOURL
  6580. struct urldata http_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  6581. #endif /* NOURL */
  6582. static int
  6583. dohttp() { /* HTTP */
  6584. struct FDB sw, kw, fi;
  6585. int n, getval, allinone = 0;
  6586. char c, * p;
  6587. char rdns[128];
  6588. char * http_agent = NULL; /* Parse results */
  6589. char * http_hdr = NULL;
  6590. char * http_user = NULL;
  6591. char * http_pass = NULL;
  6592. char * http_mime = NULL;
  6593. char * http_lfile = NULL;
  6594. char * http_rfile = NULL;
  6595. char * http_dfile = NULL;
  6596. char http_array = NUL;
  6597. int http_action = -1;
  6598. char * http_host = NULL;
  6599. char * http_srv = NULL;
  6600. int http_ssl = 0;
  6601. static char * http_d_agent = NULL;
  6602. static char * http_d_user = NULL;
  6603. static char * http_d_pass = NULL;
  6604. static int http_d_type = 0;
  6605. int http_type = http_d_type;
  6606. #ifdef OS2
  6607. p = "Kermit 95"; /* Default user agent */
  6608. #else
  6609. p = "C-Kermit";
  6610. #endif /* OS2 */
  6611. makestr(&http_agent,p);
  6612. makestr(&http_mime,"text/HTML"); /* MIME type default */
  6613. rdns[0] = '\0';
  6614. cmfdbi(&sw, /* 1st FDB - general switches */
  6615. _CMKEY, /* fcode */
  6616. "OPEN, CLOSE, GET, HEAD, PUT, INDEX, or POST,\n or switch", /* hlpmsg */
  6617. "", /* default */
  6618. "", /* addtl string data */
  6619. nhttpswtab, /* addtl numeric data 1: tbl size */
  6620. 4, /* addtl numeric data 2: 4 = cmswi */
  6621. xxstring, /* Processing function */
  6622. httpswtab, /* Keyword table */
  6623. &kw /* Pointer to next FDB */
  6624. );
  6625. cmfdbi(&kw, /* 2nd FDB - commands */
  6626. _CMKEY, /* fcode */
  6627. "Command", /* hlpmsg */
  6628. "", /* default */
  6629. "", /* addtl string data */
  6630. nhttptab, /* addtl numeric data 1: tbl size */
  6631. 0, /* addtl numeric data 2: 0 = keyword */
  6632. xxstring, /* Processing function */
  6633. httptab, /* Keyword table */
  6634. NULL /* Pointer to next FDB */
  6635. );
  6636. while (1) {
  6637. x = cmfdb(&sw); /* Parse something */
  6638. if (x < 0) /* Error */
  6639. goto xhttp;
  6640. n = cmresult.nresult;
  6641. if (cmresult.fdbaddr == &kw) /* Command - exit this loop */
  6642. break;
  6643. c = cmgbrk(); /* Switch... */
  6644. getval = (c == ':' || c == '=');
  6645. x = -9;
  6646. if (getval && !(cmgkwflgs() & CM_ARG)) {
  6647. printf("?This switch does not take an argument\n");
  6648. goto xhttp;
  6649. }
  6650. switch (cmresult.nresult) { /* Handle each switch */
  6651. case HT_SW_TP: /* /TOSCREEN */
  6652. http_type = 1;
  6653. break;
  6654. case HT_SW_AG: /* /AGENT */
  6655. if (getval) {
  6656. if ((x = cmfld("User agent",p,&s,xxstring)) < 0)
  6657. goto xhttp;
  6658. } else {
  6659. s = p;
  6660. }
  6661. makestr(&http_agent,s);
  6662. break;
  6663. case HT_SW_HD: /* /HEADER */
  6664. s = NULL;
  6665. if (getval) {
  6666. if ((x = cmfld("Header line","",&s,xxstring)) < 0) {
  6667. if (x == -3)
  6668. s = NULL;
  6669. else
  6670. goto xhttp;
  6671. }
  6672. }
  6673. makestr(&http_hdr,s);
  6674. break;
  6675. case HT_SW_US: /* /USER */
  6676. s = NULL;
  6677. if (getval) {
  6678. if ((x = cmfld("User ID","",&s,xxstring)) < 0) {
  6679. if (x == -3)
  6680. s = "";
  6681. else
  6682. goto xhttp;
  6683. }
  6684. }
  6685. makestr(&http_user,s);
  6686. break;
  6687. case HT_SW_PW: /* /PASSWORD */
  6688. debok = 0;
  6689. s = NULL;
  6690. if (getval) {
  6691. if ((x = cmfld("Password","",&s,xxstring)) < 0)
  6692. goto xhttp;
  6693. }
  6694. makestr(&http_pass,s);
  6695. break;
  6696. #ifndef NOSPL
  6697. case HT_SW_AR: { /* /ARRAY: */
  6698. char * s2, array = NUL;
  6699. if (!getval) {
  6700. printf("?This switch requires an argument\n");
  6701. x = -9;
  6702. goto xhttp;
  6703. }
  6704. if ((x = cmfld("Array name (a single letter will do)",
  6705. "",
  6706. &s,
  6707. NULL
  6708. )) < 0) {
  6709. if (x == -3) {
  6710. printf("?Array name required\n");
  6711. x = -9;
  6712. goto xhttp;
  6713. } else
  6714. goto xhttp;
  6715. }
  6716. if (!*s) {
  6717. printf("?Array name required\n");
  6718. x = -9;
  6719. goto xhttp;
  6720. }
  6721. s2 = s;
  6722. if (*s == CMDQ) s++;
  6723. if (*s == '&') s++;
  6724. if (!isalpha(*s)) {
  6725. printf("?Bad array name - \"%s\"\n",s2);
  6726. x = -9;
  6727. goto xhttp;
  6728. }
  6729. array = *s++;
  6730. if (isupper(array))
  6731. array = tolower(array);
  6732. if (*s && (*s != '[' || *(s+1) != ']')) {
  6733. printf("?Bad array name - \"%s\"\n",s2);
  6734. http_array = NUL;
  6735. x = -9;
  6736. goto xhttp;
  6737. }
  6738. http_array = array;
  6739. break;
  6740. }
  6741. #endif /* NOSPL */
  6742. default:
  6743. x = -2;
  6744. goto xhttp;
  6745. }
  6746. }
  6747. http_action = n; /* Save the action */
  6748. if (http_action == HTTP_PUT || http_action == HTTP_POS) {
  6749. cmfdbi(&sw, /* 1st FDB - switch */
  6750. _CMKEY, /* fcode */
  6751. "Local filename\n Or switch", /* help */
  6752. "", /* default */
  6753. "", /* addtl string data */
  6754. nhttpptab, /* keyword table size */
  6755. 4, /* addtl numeric data 2: 4 = cmswi */
  6756. xxstring, /* Processing function */
  6757. httpptab, /* Keyword table */
  6758. &fi /* Pointer to next FDB */
  6759. );
  6760. cmfdbi(&fi, /* 2nd FDB - filename */
  6761. _CMIFI, /* fcode */
  6762. "Local filename", /* hlpmsg */
  6763. "", /* default */
  6764. "", /* addtl string data */
  6765. 0, /* addtl numeric data 1 */
  6766. 0, /* addtl numeric data 2 */
  6767. xxstring,
  6768. NULL,
  6769. NULL
  6770. );
  6771. while (1) {
  6772. x = cmfdb(&sw);
  6773. if (x < 0)
  6774. goto xhttp; /* Free any malloc'd temp strings */
  6775. n = cmresult.nresult;
  6776. if (cmresult.fcode != _CMKEY)
  6777. break;
  6778. c = cmgbrk(); /* Switch... */
  6779. getval = (c == ':' || c == '=');
  6780. if (getval && !(cmgkwflgs() & CM_ARG)) {
  6781. printf("?This switch does not take an argument\n");
  6782. x = -9;
  6783. goto xhttp;
  6784. }
  6785. switch (n) {
  6786. case HT_PP_MT:
  6787. s = "text/HTML";
  6788. if (getval) {
  6789. if ((x = cmfld("MIME type",
  6790. "text/HTML",&s,xxstring)) < 0)
  6791. goto xhttp;
  6792. }
  6793. makestr(&http_mime,s);
  6794. break;
  6795. default:
  6796. x = -2;
  6797. goto xhttp;
  6798. }
  6799. }
  6800. makestr(&http_lfile,cmresult.sresult);
  6801. n = ckindex("/",http_lfile,-1,1,0);
  6802. if (n)
  6803. p = &http_lfile[n];
  6804. else
  6805. p = http_lfile;
  6806. if ((x = cmfld("URL or remote filename",p,&s,xxstring)) < 0) {
  6807. if (x == -3) {
  6808. printf("?%s what?\n",(http_action == HTTP_PUT) ? "Put" : "Post");
  6809. x = -9;
  6810. }
  6811. goto xhttp;
  6812. }
  6813. if (!*s) s = NULL;
  6814. makestr(&http_rfile,s);
  6815. if ((x = cmtxt("Response filename","",&s,xxstring)) < 0) {
  6816. if (x != -3)
  6817. goto xhttp;
  6818. }
  6819. if (*s)
  6820. makestr(&http_dfile,s);
  6821. }
  6822. switch (http_action) {
  6823. case HTTP_DEL: /* DELETE */
  6824. if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  6825. if (x == -3) {
  6826. printf("?Delete what?\n");
  6827. x = -9;
  6828. }
  6829. goto xhttp;
  6830. }
  6831. makestr(&http_rfile,s);
  6832. break;
  6833. case HTTP_CON: /* CONNECT */
  6834. if ((x = cmfld("Remote host[:port]","",&s,xxstring)) < 0) {
  6835. if (x == -3) {
  6836. printf("?Remote host[:port] is required\n");
  6837. x = -9;
  6838. }
  6839. goto xhttp;
  6840. }
  6841. makestr(&http_rfile,s);
  6842. break;
  6843. case HTTP_HED: { /* HEAD */
  6844. char buf[CKMAXPATH+1];
  6845. if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  6846. if (x == -3) {
  6847. printf("?Head of what?\n");
  6848. x = -9;
  6849. }
  6850. goto xhttp;
  6851. }
  6852. makestr(&http_rfile,s);
  6853. if (http_array || http_type) { /* Default result filename */
  6854. p = ""; /* None if /ARRAY or /TOSCREEN */
  6855. } else {
  6856. n = ckindex("/",http_rfile,-1,1,0); /* Otherwise strip path */
  6857. if (n) /* and add ".head" */
  6858. p = &http_rfile[n];
  6859. else
  6860. p = http_rfile;
  6861. ckmakmsg(buf,CKMAXPATH,p,".head",NULL,NULL);
  6862. p = buf;
  6863. }
  6864. if ((x = cmofi("Local filename",p,&s,xxstring)) < 0) {
  6865. if (x != -3)
  6866. goto xhttp;
  6867. }
  6868. makestr(&http_lfile,s);
  6869. break;
  6870. }
  6871. case HTTP_GET: /* GET */
  6872. case HTTP_IDX: { /* INDEX */
  6873. extern int wildena;
  6874. int tmp;
  6875. char * lfile = "";
  6876. if ((x = cmfld("URL or remote source file","",&s,xxstring)) < 0) {
  6877. if (x == -3) {
  6878. printf("?Get what?\n");
  6879. x = -9;
  6880. }
  6881. goto xhttp;
  6882. }
  6883. makestr(&http_rfile,s);
  6884. if (http_action == HTTP_GET && !http_type)
  6885. zstrip(http_rfile,&lfile);
  6886. /* URLs often contain question marks or other metacharacters */
  6887. /* cmofi() doesn't like them */
  6888. tmp = wildena;
  6889. wildena = 0;
  6890. if ((x = cmofi("Local filename",lfile,&s,xxstring)) < 0) {
  6891. wildena = tmp;
  6892. if (x != -3)
  6893. goto xhttp;
  6894. }
  6895. wildena = tmp;
  6896. makestr(&http_lfile,s);
  6897. break;
  6898. }
  6899. case HTTP_OPN: {
  6900. int sslswitch = 0;
  6901. #ifdef CK_SSL
  6902. struct FDB sw, fl;
  6903. cmfdbi(&sw,
  6904. _CMKEY, /* fcode */
  6905. "IP host name or address, or switch", /* hlpmsg */
  6906. "", /* default */
  6907. "", /* addtl string data */
  6908. 2, /* addtl numeric data 1: tbl size */
  6909. 4, /* addtl numeric data 2: 4 = cmswi */
  6910. xxstring, /* Processing function */
  6911. sslswtab, /* Keyword table */
  6912. &fl /* Pointer to next FDB */
  6913. );
  6914. cmfdbi(&fl, /* 2nd FDB - host */
  6915. _CMFLD, /* fcode */
  6916. "", /* hlpmsg */
  6917. "", /* default */
  6918. "", /* addtl string data */
  6919. 0, /* addtl numeric data 1 */
  6920. 0, /* addtl numeric data 2 */
  6921. xxstring,
  6922. NULL,
  6923. NULL
  6924. );
  6925. x = cmfdb(&sw); /* Parse switch or host */
  6926. if (x < 0) /* Error */
  6927. goto xhttp;
  6928. if (cmresult.fcode == _CMFLD) { /* Host */
  6929. s = cmresult.sresult; /* Set up expected pointer */
  6930. goto havehost; /* Go parse rest of command */
  6931. }
  6932. sslswitch = 1; /* /SSL or /TLS switch - set flag */
  6933. #endif /* CK_SSL */
  6934. /* Parse host */
  6935. if ((x = cmfld("URL, hostname, or ip-address","",&s,xxstring)) < 0) {
  6936. if (x == -3) {
  6937. printf("?Open what?\n");
  6938. x = -9;
  6939. }
  6940. goto xhttp;
  6941. }
  6942. havehost: /* Come here with s -> host */
  6943. #ifdef CK_URL
  6944. x = urlparse(s,&http_url); /* Was a URL given? */
  6945. if (x < 1) { /* Not a URL */
  6946. #endif /* CK_URL */
  6947. makestr(&http_host,s);
  6948. if ((x =
  6949. cmfld("Service name or port number",
  6950. sslswitch ? "https" : "http",&s,xxstring)) < 0)
  6951. goto xhttp;
  6952. else
  6953. makestr(&http_srv,s);
  6954. #ifdef CK_URL
  6955. } else if (ckstrcmp(http_url.svc,"http",-1,0) && /* Non-HTTP URL */
  6956. ckstrcmp(http_url.svc,"https",-1,0)) {
  6957. printf("?Non-HTTP URL\n");
  6958. x = -9;
  6959. goto xhttp;
  6960. } else { /* Have HTTP URL */
  6961. makestr(&http_srv, http_url.svc);
  6962. makestr(&http_user,http_url.usr);
  6963. makestr(&http_pass,http_url.psw);
  6964. makestr(&http_host,http_url.hos);
  6965. if (http_url.por)
  6966. makestr(&http_srv,http_url.por);
  6967. makestr(&http_rfile,http_url.pth);
  6968. }
  6969. if (http_rfile) { /* Open, GET, and Close */
  6970. printf("?Directory/file path not allowed in HTTP OPEN URL\n");
  6971. x = -9;
  6972. goto xhttp;
  6973. }
  6974. if (!ckstrcmp("https",http_srv,-1,0) || sslswitch ||
  6975. !ckstrcmp("443",http_srv,-1,0))
  6976. http_ssl = 1;
  6977. #endif /* CK_URL */
  6978. break;
  6979. }
  6980. case HTTP_CLS:
  6981. break;
  6982. }
  6983. if ((x = cmcfm()) < 0)
  6984. goto xhttp;
  6985. if (http_action == HTTP_OPN) {
  6986. x = (http_open(http_host,http_srv,http_ssl,rdns,128,http_agent) == 0);
  6987. if (x) {
  6988. if (!quiet) {
  6989. if (rdns[0])
  6990. printf("Connected to %s [%s]\r\n",http_host,rdns);
  6991. else
  6992. printf("Connected to %s\r\n",http_host);
  6993. }
  6994. if (http_agent) {
  6995. if (http_d_agent)
  6996. free(http_d_agent);
  6997. http_d_agent = http_agent;
  6998. http_agent = NULL;
  6999. }
  7000. if (http_user) {
  7001. if (http_d_user)
  7002. free(http_d_user);
  7003. http_d_user = http_user;
  7004. http_user = NULL;
  7005. }
  7006. if (http_pass) {
  7007. if (http_d_pass) {
  7008. memset(http_d_pass,0,strlen(http_d_pass));
  7009. free(http_d_pass);
  7010. }
  7011. http_d_pass = http_pass;
  7012. http_pass = NULL;
  7013. }
  7014. http_d_type = http_type;
  7015. } else {
  7016. if (!quiet)
  7017. printf("?HTTP Connection failed.\r\n");
  7018. }
  7019. } else if (http_action == HTTP_CLS) {
  7020. if (http_d_agent) {
  7021. free(http_d_agent);
  7022. http_d_agent = NULL;
  7023. }
  7024. if (http_d_user) {
  7025. free(http_d_user);
  7026. http_d_user = NULL;
  7027. }
  7028. if (http_d_pass) {
  7029. memset(http_d_pass,0,strlen(http_d_pass));
  7030. free(http_d_pass);
  7031. http_d_pass = NULL;
  7032. }
  7033. http_d_type = 0;
  7034. x = (http_close() == 0);
  7035. }
  7036. if ((http_action != HTTP_CLS) &&
  7037. (http_action != HTTP_CON) && http_rfile) { /* Remote file is URL? */
  7038. /* All-in-one actions when a URL is given... */
  7039. #ifdef CK_URL
  7040. if (urlparse(http_rfile,&http_url) > 0) { /* Have URL? */
  7041. if (ckstrcmp(http_url.svc,"http",-1,0) && /* It's an HTTP URL? */
  7042. ckstrcmp(http_url.svc,"https",-1,0)) {
  7043. printf("?Non-HTTP URL\n");
  7044. x = -9;
  7045. goto xhttp;
  7046. } else { /* Yes, collect the pieces */
  7047. makestr(&http_srv, http_url.svc);
  7048. makestr(&http_user,http_url.usr);
  7049. makestr(&http_pass,http_url.psw);
  7050. makestr(&http_host,http_url.hos);
  7051. if (http_url.por)
  7052. makestr(&http_srv,http_url.por);
  7053. makestr(&http_rfile,http_url.pth);
  7054. }
  7055. if (!http_rfile) { /* Still have a path? */
  7056. makestr(&http_rfile,"/");
  7057. }
  7058. if (!ckstrcmp("https",http_srv,-1,0) || /* Check for SSL/TLS */
  7059. !ckstrcmp("443",http_srv,-1,0))
  7060. http_ssl = 1;
  7061. if (http_isconnected()) /* Close any open HTTP connection */
  7062. http_close();
  7063. if (http_pass == NULL && http_d_pass != NULL)
  7064. makestr(&http_pass,http_d_pass);
  7065. x = (http_open(http_host,
  7066. http_srv,http_ssl,rdns,128,http_d_agent) == 0);
  7067. if (x < 0) {
  7068. x = 0;
  7069. goto xhttp;
  7070. }
  7071. allinone = 1;
  7072. }
  7073. #endif /* CK_URL */
  7074. if (http_pass == NULL && http_d_pass != NULL)
  7075. makestr(&http_pass,http_d_pass);
  7076. if (http_action == HTTP_OPN && allinone) {
  7077. http_action = HTTP_GET;
  7078. }
  7079. x = xdohttp(http_action,
  7080. http_lfile,
  7081. http_rfile,
  7082. http_dfile,
  7083. http_agent ? http_agent : http_d_agent,
  7084. http_hdr,
  7085. http_user ? http_user : http_d_user,
  7086. http_pass ? http_pass : http_d_pass,
  7087. http_mime,
  7088. http_array,
  7089. http_type
  7090. );
  7091. if (allinone)
  7092. x = (http_close() == 0);
  7093. }
  7094. xhttp:
  7095. if (http_agent) free(http_agent);
  7096. if (http_hdr) free(http_hdr);
  7097. if (http_user) free(http_user);
  7098. if (http_pass) {
  7099. memset(http_pass,0,strlen(http_pass));
  7100. free(http_pass);
  7101. }
  7102. if (http_mime) free(http_mime);
  7103. if (http_lfile) free(http_lfile);
  7104. if (http_rfile) free(http_rfile);
  7105. if (http_dfile) free(http_dfile);
  7106. if (http_host) free(http_host);
  7107. if (http_srv) free(http_srv);
  7108. if (x > -1)
  7109. success = x;
  7110. return(x);
  7111. }
  7112. #endif /* TCPSOCKET */
  7113. #endif /* NOHTTP */
  7114. #ifndef NOSPL
  7115. static int
  7116. dotrace() {
  7117. int on = 1;
  7118. struct FDB sw, kw;
  7119. cmfdbi(&sw, /* 1st FDB - switch */
  7120. _CMKEY, /* fcode */
  7121. "Trace object;\n Or switch", /* help */
  7122. "", /* default */
  7123. "", /* addtl string data */
  7124. 2, /* keyword table size */
  7125. 4, /* addtl numeric data 2: 4 = cmswi */
  7126. xxstring, /* Processing function */
  7127. onoffsw, /* Keyword table */
  7128. &kw /* Pointer to next FDB */
  7129. );
  7130. cmfdbi(&kw, /* 2nd FDB - Trace object */
  7131. _CMKEY, /* fcode */
  7132. "Trace object", /* help */
  7133. "all", /* default */
  7134. "", /* addtl string data */
  7135. ntracetab, /* keyword table size */
  7136. 0, /* addtl numeric data 2: 0 = keyword */
  7137. xxstring, /* Processing function */
  7138. tracetab, /* Keyword table */
  7139. NULL /* Pointer to next FDB */
  7140. );
  7141. if ((x = cmfdb(&sw)) < 0)
  7142. return(x);
  7143. if (cmresult.fdbaddr == &sw) {
  7144. on = cmresult.nresult;
  7145. if ((x = cmkey(tracetab, ntracetab,"","all",xxstring)) < 0)
  7146. return(x);
  7147. } else {
  7148. x = cmresult.nresult;
  7149. }
  7150. if ((y = cmcfm()) < 0)
  7151. return(y);
  7152. switch (x) {
  7153. case TRA_ASG:
  7154. tra_asg = on;
  7155. break;
  7156. case TRA_CMD:
  7157. tra_cmd = on;
  7158. break;
  7159. case TRA_ALL:
  7160. tra_asg = on;
  7161. tra_cmd = on;
  7162. break;
  7163. default:
  7164. return(-2);
  7165. }
  7166. printf("TRACE %s\n", on ? "ON" : "OFF");
  7167. return(success = 1);
  7168. }
  7169. #endif /* NOSPL */
  7170. static int
  7171. doprompt() {
  7172. extern int xcmdsrc;
  7173. if ((x = cmtxt("Optional message","",&s,xxstring)) < 0)
  7174. return(x);
  7175. #ifdef NOSPL
  7176. printf("?Sorry, PROMPT requires script programming language\n");
  7177. return(-9);
  7178. #else
  7179. debug(F101,"Prompt cmdlvl","",cmdlvl);
  7180. cmdlvl++;
  7181. if (cmdlvl > CMDSTKL) {
  7182. printf("?Command stack overflow: %d\n",cmdlvl);
  7183. cmdlvl--;
  7184. return(-9);
  7185. }
  7186. xcmdsrc = CMD_KB;
  7187. cmdstk[cmdlvl].src = CMD_KB; /* Say we're at the prompt */
  7188. cmdstk[cmdlvl].lvl = 0;
  7189. cmdstk[cmdlvl].ccflgs = cmdstk[cmdlvl-1].ccflgs;
  7190. if (tra_cmd)
  7191. printf("[%d] +P: \"(prompt)\"\n",cmdlvl);
  7192. concb((char)escape);
  7193. if (!quiet)
  7194. printf(
  7195. "(Recursive command prompt: Resume script with CONTINUE, STOP to stop...)\n"
  7196. );
  7197. if (*s) { /* If prompt given */
  7198. makestr(&(prstring[cmdlvl-1]),cmgetp()); /* Save current prompt */
  7199. cmsetp(s); /* Set new one */
  7200. }
  7201. return(success = 1);
  7202. #endif /* NOSPL */
  7203. }
  7204. #ifdef CKLEARN
  7205. VOID
  7206. learncmd(s) char *s; { /* Record commands in learned script */
  7207. char buf[64];
  7208. int i, k;
  7209. if (learnfp && learning) { /* Only if open and on */
  7210. k = ckstrncpy(buf,s,64);
  7211. for (i = 0; i < k; i++) { /* Get top-level command keyword */
  7212. if (buf[i] <= SP) {
  7213. buf[i] = NUL;
  7214. break;
  7215. }
  7216. }
  7217. k = lookup(cmdtab,buf,ncmd,NULL); /* Look it up */
  7218. if (k == XXCON || k == XXLEARN) /* Don't record CONNECT or LEARN */
  7219. return;
  7220. if (k == XXTEL) {
  7221. fputs("SET HOST /NETWORK:TCP",learnfp);
  7222. fputs(&s[i],learnfp);
  7223. fputs(" TELNET /TELNET",learnfp);
  7224. fputs("\nIF FAIL STOP 1 Connection failed\n",learnfp);
  7225. } else {
  7226. fputs(s,learnfp);
  7227. fputs("\n",learnfp);
  7228. }
  7229. }
  7230. }
  7231. #endif /* CKLEARN */
  7232. #ifdef SSHCMD
  7233. /*
  7234. 2010/03/01...
  7235. Reopen a connection that was made with an external ssh client
  7236. after it has been closed.
  7237. */
  7238. int
  7239. redossh() {
  7240. int x, netsave;
  7241. x = nettype;
  7242. debug(F111,"redossh nettype",ttname,nettype);
  7243. if ((y = setlin(XXSSH,0,1)) < 0) {
  7244. if (errno)
  7245. printf("?%s\n",ck_errstr());
  7246. else
  7247. return(y);
  7248. nettype = x; /* Failed, restore net type. */
  7249. success = 0;
  7250. return(y);
  7251. }
  7252. netsave = x;
  7253. return(y);
  7254. }
  7255. #endif /* SSHCMD */
  7256. /*
  7257. Like hmsga() in ckuus2.c but takes a single substitution parameter, s2,
  7258. which replaces every occurrence of "%s" in the first argument.
  7259. Added to print text containing the copyright year, so the year doesn't
  7260. have to be hardwired into lots of scattered text strings.
  7261. */
  7262. int /* Print an array of lines, */
  7263. #ifdef CK_ANSIC
  7264. hmsgaa(char *s[], char *s2) /* pausing at end of each screen. */
  7265. #else
  7266. hmsgaa(s,s2) char *s[]; char *s2;
  7267. #endif /* CK_ANSIC */
  7268. {
  7269. extern int hmtopline;
  7270. #ifdef OS2
  7271. extern int tt_rows[], tt_cols[];
  7272. #else /* OS2 */
  7273. extern int tt_rows, tt_cols;
  7274. #endif /* OS2 */
  7275. int x, y, i, j, k, n;
  7276. if ((x = cmcfm()) < 0) return(x);
  7277. #ifdef CK_TTGWSIZ
  7278. #ifdef OS2
  7279. ttgcwsz();
  7280. #else /* OS2 */
  7281. /* Check whether window size changed */
  7282. if (ttgwsiz() > 0) {
  7283. if (tt_rows > 0 && tt_cols > 0) {
  7284. cmd_rows = tt_rows;
  7285. cmd_cols = tt_cols;
  7286. }
  7287. }
  7288. #endif /* OS2 */
  7289. #endif /* CK_TTGWSIZ */
  7290. printf("\n"); /* Start off with a blank line */
  7291. n = (hmtopline > 0) ? hmtopline : 1; /* Line counter */
  7292. for (i = 0; *s[i]; i++) {
  7293. printf((char *)s[i],s2); /* Print a line. */
  7294. printf("\n");
  7295. y = (int)strlen(s[i]);
  7296. k = 1;
  7297. for (j = 0; j < y; j++) /* See how many newlines were */
  7298. if (s[i][j] == '\n') k++; /* in the string... */
  7299. n += k;
  7300. if (n > (cmd_rows - 3) && *s[i+1]) /* After a screenful, give them */
  7301. if (!askmore()) return(0); /* a "more?" prompt. */
  7302. else n = 0;
  7303. }
  7304. printf("\n");
  7305. return(0);
  7306. }
  7307. /* I S I N T E R N A L M A C R O -- April 2017 */
  7308. int
  7309. isinternalmacro(x) int x; { /* Test if macro is internally defined */
  7310. char * m;
  7311. char * tags[] = { "_whi", "_for", "_sw_", "_if_" };
  7312. int i, internal = 0;
  7313. m = mactab[x].kwd;
  7314. #ifdef COMMENT
  7315. /* Good idea but this flag is not set for _whi2, etc */
  7316. internal = ((cmdstk[cmdlvl].ccflgs & CF_IMAC) ? 1 : 0);
  7317. debug(F111,"isinternalmacro",m,internal);
  7318. return(internal);
  7319. #endif /* COMMENT */
  7320. debug(F101,"isinternalmacro x","",x);
  7321. if (*m != '_') {
  7322. debug(F110," not internal",m,0);
  7323. return(0);
  7324. }
  7325. if (!m) m = "";
  7326. if (*m) {
  7327. debug(F110," macro name",m,0);
  7328. internal = ckindex(m,"|_while|_forx|_forz|_xif|_switx|",0,0,0);
  7329. debug(F111," internal macro","A",internal);
  7330. if (!internal) {
  7331. int i, j, n, len = 0;
  7332. n = -1;
  7333. for (i = 0; i < sizeof(* tags); i++) {
  7334. if (ckindex(tags[i],m,0,0,0)) {
  7335. n = i;
  7336. break;
  7337. }
  7338. }
  7339. debug(F111," tags index",tags[n],n);
  7340. if (n > -1) {
  7341. char * tag = tags[i];
  7342. len = (int)strlen(tag);
  7343. debug(F111," tag len",tag,len);
  7344. for (i = len; m[i]; i++) {
  7345. debug(F101," loop i","",i);
  7346. debug(F000," char","",m[i]);
  7347. if (!isdigit(m[i])) {
  7348. internal = 0;
  7349. break;
  7350. } else {
  7351. internal = 1;
  7352. }
  7353. }
  7354. }
  7355. debug(F101," internal macro","B",internal);
  7356. }
  7357. }
  7358. return(internal);
  7359. }
  7360. /* N E W E R R M S G -- New error message routine, April 2017 */
  7361. #define ERRMSGBUFSIZ 320
  7362. static char errmsgbuf[ERRMSGBUFSIZ] = { '\0' };
  7363. VOID newerrmsg(s) char *s; {
  7364. char * tmperrbuf[ERRMSGBUFSIZ];
  7365. extern char lasttakeline[];
  7366. extern char *tfnam[];
  7367. extern int tfblockstart[];
  7368. extern int tlevel;
  7369. int len1, len2, len3, len4, len5;
  7370. char * buf = errmsgbuf;
  7371. char * takefile = getbasename(tfnam[tlevel]);
  7372. char nbuf[20];
  7373. char * lineno = nbuf;
  7374. int x;
  7375. debug(F110,"newerrmsg",s,0);
  7376. ckstrncpy(nbuf,ckitoa(tfblockstart[tlevel]),20);
  7377. lineno = (char *)nbuf;
  7378. if (!s) s = "";
  7379. if (!*s) s = "Syntax error";
  7380. if (tlevel < 0) {
  7381. printf("?%s\n",s);
  7382. return;
  7383. }
  7384. len1 = (int)strlen(s);
  7385. len2 = (int)strlen(takefile);
  7386. len3 = (int)strlen(lineno);
  7387. len4 = (int)strlen((char *)lasttakeline);
  7388. len5 = len1 + len2 + len3 + 12;
  7389. x = 80 - len5; /* Free space for beginning of offending command */
  7390. if (x > len4) { /* Free space is greater than command length */
  7391. #ifdef HAVE_SNPRINTF
  7392. snprintf((char *)tmperrbuf,ERRMSGBUFSIZ,"?%s[%s]: \"%s\": %s\n",
  7393. takefile,
  7394. lineno,
  7395. (char *)lasttakeline,
  7396. s
  7397. );
  7398. #else
  7399. sprintf((char *)tmperrbuf,"?%s[%s]: \"%s\": %s\n",
  7400. takefile,
  7401. lineno,
  7402. (char *)lasttakeline,
  7403. s
  7404. );
  7405. #endif /* HAVE_SNPRINTF */
  7406. } else if (x > 40) {
  7407. char c;
  7408. c = lasttakeline[x];
  7409. lasttakeline[x] = NUL;
  7410. #ifdef HAVE_SNPRINTF
  7411. snprintf((char *)tmperrbuf,ERRMSGBUFSIZ,"?%s[%s]: \"%s...\": %s\n",
  7412. takefile, lineno, (char *)lasttakeline, s);
  7413. #else
  7414. sprintf((char *)tmperrbuf,"?%s[%s]: \"%s...\": %s\n",
  7415. takefile, lineno, (char *)lasttakeline, s);
  7416. #endif /* HAVE_SNPRINTF */
  7417. lasttakeline[x] = c;
  7418. } else {
  7419. char c;
  7420. if (len4 > 74) {
  7421. x = 74 - (len2 + len3 + 8);
  7422. c = lasttakeline[x];
  7423. lasttakeline[x] = NUL;
  7424. #ifdef HAVE_SNPRINTF
  7425. snprintf((char *)tmperrbuf,ERRMSGBUFSIZ,
  7426. "?%s[%s]: \"%s...\":\n Error: %s\n",
  7427. takefile, lineno, (char *)lasttakeline, s);
  7428. #else
  7429. sprintf((char *)tmperrbuf,"?%s[%s]: \"%s...\":\n Error: %s\n",
  7430. takefile, lineno, (char *)lasttakeline, s);
  7431. #endif /* HAVE_SNPRINTF */
  7432. lasttakeline[x] = c;
  7433. } else {
  7434. #ifdef HAVE_SNPRINTF
  7435. snprintf((char *)tmperrbuf,ERRMSGBUFSIZ,
  7436. "?%s[%s]: \"%s\":\n %s\n",
  7437. takefile, lineno, (char *)lasttakeline, s);
  7438. #else
  7439. sprintf((char *)tmperrbuf,"?%s[%s]: \"%s\":\n %s\n",
  7440. takefile, lineno, (char *)lasttakeline, s);
  7441. #endif /* HAVE_SNPRINTF */
  7442. }
  7443. }
  7444. xnewerrmsg:
  7445. /* Print the message only if it's not the same as the last one */
  7446. if (ckstrcmp((char *)errmsgbuf,(char *)tmperrbuf,ERRMSGBUFSIZ,1)) {
  7447. ckstrncpy((char *)errmsgbuf,(char *)tmperrbuf,ERRMSGBUFSIZ);
  7448. printf("%s",(char *)errmsgbuf);
  7449. }
  7450. return;
  7451. }
  7452. /* D O C M D -- Do a command */
  7453. /*
  7454. Returns:
  7455. -2: user typed an illegal command
  7456. -1: reparse needed
  7457. 0: parse was successful (even tho command may have failed).
  7458. */
  7459. #ifdef DEBUG
  7460. int cmdstats[256] = { -1, -1 };
  7461. #endif /* DEBUG */
  7462. int
  7463. docmd(cx) int cx; {
  7464. extern int nolocal, cmkwflgs;
  7465. debug(F101,"docmd entry, cx","",cx);
  7466. activecmd = cx;
  7467. doconx = ((activecmd == XXCON) || (activecmd == XXTEL) ||
  7468. (activecmd == XXRLOG) || (activecmd == XXPIPE) ||
  7469. (activecmd == XXIKSD) || (activecmd == XXPTY));
  7470. /*
  7471. Originally all commands were handled with a big switch() statement,
  7472. but eventually this started blowing up compilers. Now we have a series
  7473. of separate if statements and small switches, with the commands that are
  7474. most commonly executed in scripts and loops coming first, to speed up
  7475. compute-bound scripts.
  7476. */
  7477. #ifdef DEBUG
  7478. if (cmdstats[0] == -1) { /* Count commands */
  7479. int i; /* for tuning... */
  7480. for (i = 0; i < 256; i++)
  7481. cmdstats[i] = 0;
  7482. }
  7483. #endif /* DEBUG */
  7484. switch (cx) {
  7485. case -4: /* EOF */
  7486. #ifdef OSK
  7487. if (msgflg) printf("\n");
  7488. #else
  7489. if (msgflg) printf("\r\n");
  7490. #endif /* OSK */
  7491. doexit(GOOD_EXIT,xitsta);
  7492. case -3: /* Null command */
  7493. return(0);
  7494. case -9: /* Like -2, but errmsg already done */
  7495. case -1: /* Reparse needed */
  7496. return(cx);
  7497. case -6: /* Special */
  7498. case -2: /* Error, maybe */
  7499. #ifndef NOSPL
  7500. /*
  7501. Maybe they typed a macro name. Let's look it up and see.
  7502. */
  7503. if (cx == -6) /* If they typed CR */
  7504. ckstrncat(cmdbuf,"\015",CMDBL); /* add it back to command buffer. */
  7505. if (ifcmd[cmdlvl] == 2) /* Watch out for IF commands. */
  7506. ifcmd[cmdlvl]--;
  7507. repars = 1; /* Force reparse */
  7508. cmres();
  7509. cx = XXDO; /* Try DO command */
  7510. #else
  7511. return(cx);
  7512. #endif /* NOSPL */
  7513. default:
  7514. if (cx < 0)
  7515. return(cx);
  7516. break;
  7517. }
  7518. #ifdef DEBUG
  7519. if (cx < 256)
  7520. cmdstats[cx]++;
  7521. #endif /* DEBUG */
  7522. if ((cmkwflgs & CM_PSH)
  7523. #ifndef NOPUSH
  7524. && nopush
  7525. #endif /* NOPUSH */
  7526. ) {
  7527. printf("?Access to system disabled\n");
  7528. return(-9);
  7529. }
  7530. if ((cmkwflgs & CM_LOC)
  7531. #ifndef NOLOCAL
  7532. && nolocal
  7533. #endif /* NOLOCAL */
  7534. ) {
  7535. printf("?Connections disabled\n");
  7536. return(-9);
  7537. }
  7538. #ifndef NOSPL
  7539. /* Used in FOR loops */
  7540. if (cx == XX_INCR || cx == XXINC || /* _INCREMENT, INCREMENT */
  7541. cx == XX_DECR || cx == XXDEC) /* _DECREMENT, DECREMENT */
  7542. return(doincr(cx));
  7543. /* Define (or change the definition of) a macro or variable */
  7544. if (cx == XXUNDEF || cx == XXUNDFX) {
  7545. #ifdef IKSD
  7546. if (inserver && !ENABLED(en_asg)) {
  7547. printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7548. return(-9);
  7549. }
  7550. #endif /* IKSD */
  7551. return(doundef(cx)); /* [_]UNDEFINE */
  7552. }
  7553. if (cx == XXDEF || cx == XXASS ||
  7554. cx == XXDFX || cx == XXASX) {
  7555. #ifdef IKSD
  7556. if (inserver && !ENABLED(en_asg)) {
  7557. printf("?Sorry, DEFINE/ASSIGN disabled\n");
  7558. return(-9);
  7559. }
  7560. #endif /* IKSD */
  7561. if (atmbuf[0] == '.' && !atmbuf[1]) /* "." entered as keyword */
  7562. xxdot = 1; /* i.e. with space after it... */
  7563. return(dodef(cx)); /* DEFINE, ASSIGN, etc... */
  7564. }
  7565. /* IF, WHILE, and friends */
  7566. if (cx == XXIF || cx == XXIFX || cx == XXWHI || cx == XXASSER) {
  7567. return(doif(cx));
  7568. }
  7569. if (cx == XXSWIT) { /* SWITCH */
  7570. return(doswitch());
  7571. }
  7572. /* GOTO, FORWARD, and _FORWARD (used internally by FOR, WHILE, etc) */
  7573. if (cx == XXGOTO || cx == XXFWD || cx == XXXFWD) { /* GOTO or FORWARD */
  7574. /* Note, here we don't set SUCCESS/FAILURE flag */
  7575. #ifdef COMMENT
  7576. if ((y = cmfld("label","",&s,xxstring)) < 0) {
  7577. if (y == -3) {
  7578. if (cx != XXXFWD) {
  7579. printf("?Label name required\n");
  7580. return(-9);
  7581. }
  7582. } else
  7583. return(y);
  7584. }
  7585. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  7586. if ((x = cmcfm()) < 0) return(x);
  7587. #else
  7588. if ((y = cmtxt("label","",&s,xxstring)) < 0) {
  7589. if (y == -3) {
  7590. if (cx != XXXFWD) {
  7591. printf("?GOTO: Label name required: \"%s\" \"%s\"\n",
  7592. atmbuf,
  7593. cmdbuf);
  7594. return(-9);
  7595. }
  7596. } else
  7597. return(y);
  7598. }
  7599. ckstrncpy(tmpbuf,brstrip(s),TMPBUFSIZ);
  7600. #endif /* COMMENT */
  7601. s = tmpbuf;
  7602. debug(F111,"GOTO target",s,cx);
  7603. return(dogoto(s,cx));
  7604. }
  7605. if (cx == XXDO || cx == XXMACRO) { /* DO (a macro) */
  7606. char mnamebuf[16]; /* (buffer for controlled temp name) */
  7607. struct FDB kw, fl;
  7608. int mx; /* Macro index (on stack!) */
  7609. debug(F101,"XXMACRO 0",line,cx);
  7610. if (cx == XXDO) {
  7611. if (nmac == 0) {
  7612. printf("\n?No macros defined\n");
  7613. return(-9);
  7614. }
  7615. for (y = 0; y < nmac; y++) { /* copy the macro table into a */
  7616. mackey[y].kwd = mactab[y].kwd; /* regular keyword table */
  7617. mackey[y].kwval = y; /* with value = pointer to macro tbl */
  7618. mackey[y].flgs = mactab[y].flgs;
  7619. }
  7620. cmfdbi(&kw, /* First FDB - macro name */
  7621. _CMKEY, /* fcode */
  7622. "Macro", /* hlpmsg */
  7623. "", /* default */
  7624. "", /* addtl string data */
  7625. nmac, /* addtl numeric data 1: tbl size */
  7626. 0, /* addtl numeric data 2: 0 = cmkey */
  7627. xxstring, /* Processing function */
  7628. mackey, /* Keyword table */
  7629. &fl /* Pointer to next FDB */
  7630. );
  7631. cmfdbi(&fl, /* 2nd FDB - for "{" */
  7632. _CMFLD, /* fcode */
  7633. "", /* hlpmsg */
  7634. "",
  7635. "", /* addtl string data */
  7636. 0, /* addtl numeric data 1 */
  7637. 0, /* addtl numeric data 2 */
  7638. xxstring,
  7639. NULL,
  7640. NULL
  7641. );
  7642. x = cmfdb(&kw); /* Parse something */
  7643. if (x < 0) { /* Error */
  7644. if (x == -3) {
  7645. printf("?Macro name required\n");
  7646. return(-9);
  7647. } else
  7648. return(x);
  7649. }
  7650. if (cmresult.fcode == _CMKEY) {
  7651. extern int mtchanged;
  7652. char * macroname = NULL;
  7653. /* In case args include an \fexec() that changes the macro table */
  7654. mx = x; /* Save macro index on stack */
  7655. mtchanged = 0; /* Mark state of macro table */
  7656. makestr(&macroname,mactab[mx].kwd); /* Save name */
  7657. /*
  7658. Prior to C-Kermit 9.0.304 Dev.22, April 23, 2017, cmtxt() was called in
  7659. all cases with zzstring. But this fouled up the identification of macro
  7660. arguments when their values contained grouping characters such as
  7661. doublequotes and braces. Now we defer the evaluation of the macro
  7662. arguments until after the arguments themselves have been correctly
  7663. identified. An exception is made for the internal macros that implement
  7664. the FOR, WHILE, IF, and SWITCH commands.
  7665. */
  7666. if (isinternalmacro(x)) {
  7667. debug(F100,"DO parser internal macro","",0);
  7668. if ((y = cmtxt("optional arguments","",&s,zzstring)) < 0)
  7669. return(y); /* Get macro args */
  7670. } else {
  7671. debug(F100,"DO parser normal macro","",0);
  7672. if ((y = cmtxt("optional arguments","",&s,NULL)) < 0)
  7673. return(y); /* Get macro args */
  7674. }
  7675. if (mtchanged) { /* Macro table changed? */
  7676. mx = mlook(mactab,macroname,nmac); /* Look up name again */
  7677. }
  7678. if (macroname)
  7679. free(macroname);
  7680. return(dodo(mx,s,cmdstk[cmdlvl].ccflgs) < 1 ?
  7681. (success = 0) : 1);
  7682. }
  7683. ckstrncpy(line,cmresult.sresult,LINBUFSIZ); /* _CMFLD */
  7684. if (atmbuf[0] == '{') {
  7685. if ((y = cmcfm()) < 0)
  7686. return(y);
  7687. }
  7688. } else { /* XXMACRO ("immediate macro") */
  7689. int k = 0;
  7690. line[k++] = '{';
  7691. line[k++] = SP;
  7692. line[k] = NUL;
  7693. debug(F111,"XXMACRO A",line,k);
  7694. if ((y = cmtxt("Braced list of commands","",&s,xxstring)) < 0)
  7695. return(y);
  7696. k = ckstrncpy(line+k,s,LINBUFSIZ-k);
  7697. debug(F111,"XXMACRO B",line,k);
  7698. }
  7699. x = strlen(line);
  7700. if ((line[0] == '{' && line[x-1] != '}') || line[0] == '}')
  7701. return(-2);
  7702. if (line[0] != '{' && line[x-1] != '}') {
  7703. /* Unknown command. If ON_UNKNOWN_COMMAND macro is defined, */
  7704. /* parse args and then execute it, but only if it is not */
  7705. /* already active. */
  7706. int k = -1;
  7707. if (!unkmacro) {
  7708. k = mxlook(mactab,"on_unknown_command",nmac);
  7709. }
  7710. if (k > -1) {
  7711. ckstrncpy(tmpbuf,atmbuf,TMPBUFSIZ);
  7712. z = maclvl; /* Save the current maclvl */
  7713. if ((y = cmtxt("text","",&s,xxstring)) < 0)
  7714. return(y);
  7715. ckstrncat(tmpbuf," ",TMPBUFSIZ);
  7716. ckstrncat(tmpbuf,s,TMPBUFSIZ);
  7717. unkmacro = 1;
  7718. debug(F110,"ON_UNKNOWN_COMMAND",s,0);
  7719. dodo(k,tmpbuf,cmdstk[cmdlvl].ccflgs); /* Run the macro */
  7720. while (maclvl > z) {
  7721. sstate = (CHAR) parser(1);
  7722. if (sstate) proto();
  7723. }
  7724. debug(F101,"UNKMAC loop exit maclvl","",maclvl);
  7725. unkmacro = 0;
  7726. return(success);
  7727. }
  7728. if (x > 0)
  7729. printf("?Not a command or macro name: \"%s\"\n",line);
  7730. else
  7731. printf("?Not a command or macro name.\n");
  7732. return(-9);
  7733. }
  7734. s = brstrip(line);
  7735. sprintf(mnamebuf," ..tmp:%03d",cmdlvl); /* safe (16) */
  7736. x = addmac(mnamebuf,s);
  7737. return(dodo(x,NULL,cmdstk[cmdlvl].ccflgs) < 1 ? (success = 0) : 1);
  7738. }
  7739. if (cx == XXLBL) { /* LABEL */
  7740. if ((x = cmfld("label","",&s,xxstring)) < 0) {
  7741. if (x == -3) {
  7742. #ifdef COMMENT
  7743. printf("?LABEL: Label name required: \"%s\"\n", cmdbuf);
  7744. return(-9);
  7745. #else
  7746. s = "";
  7747. #endif /* COMMENT */
  7748. } else return(x);
  7749. }
  7750. debug(F111,"LABEL",s,x);
  7751. if ((x = cmcfm()) < 0) return(x);
  7752. return(0);
  7753. }
  7754. if (cx == XXEVAL || cx == XX_EVAL) /* _EVALUATE, EVALUATE */
  7755. return(doeval(cx));
  7756. #ifndef NOSEXP
  7757. if (cx == XXSEXP) { /* Lisp-like S-Expression */
  7758. struct stringarray * q;
  7759. char /* *p, *r, */ *tmp, *m;
  7760. int i, k, n, quote = 0, contd = 0, size = 0, len = 0;
  7761. extern int sexprc, sexppv;
  7762. tmp = tmpbuf; /* Buffer to collect SEXP */
  7763. tmpbuf[0] = NUL; /* Clear it */
  7764. size = TMPBUFSIZ; /* Capacity of buffer */
  7765. sexprc = -1; /* Assume bad input */
  7766. n = 0; /* Paren balance counter */
  7767. while (1) { /* Allow SEXP on multiple lines */
  7768. m = contd ?
  7769. "Continuation of S-Expression" :
  7770. "S-Expression (\"help sexp\" for details)";
  7771. x = cmtxt(m,"",&s,xxstring);
  7772. if (x < 0)
  7773. return(x);
  7774. if (!*s) /* Needed for (=) and (:) */
  7775. s = cmdbuf+1; /* I can't explain why. */
  7776. k = ckmakmsg(tmp, size, contd ? " " : "(", s, NULL, NULL);
  7777. if (k < 1) {
  7778. printf("?SEXP too long - %d max\n",TMPBUFSIZ);
  7779. return(-9);
  7780. }
  7781. debug(F111,contd ? "sexp contd" : "sexp",s,k);
  7782. for (i = len; i < len+k; i++) { /* Check balance */
  7783. if (!quote && tmpbuf[i] == CMDQ) {
  7784. quote = 1;
  7785. continue;
  7786. }
  7787. if (quote) {
  7788. quote = 0;
  7789. continue;
  7790. }
  7791. if (tmpbuf[i] == '(')
  7792. n++;
  7793. else if (tmpbuf[i] == ')')
  7794. n--;
  7795. }
  7796. if (n == 0) { /* Break when balanced */
  7797. break;
  7798. }
  7799. if (n < 0) { /* Too many right parens */
  7800. printf("?Unbalanced S-Expression: \"%s\"\n",tmpbuf);
  7801. return(-9);
  7802. }
  7803. contd++; /* Need more right parens */
  7804. cmini(ckxech); /* so keep parsing */
  7805. tmp += k; /* adjust buffer pointer */
  7806. size -= k; /* and capacity */
  7807. len += k; /* and length so far */
  7808. }
  7809. s = tmpbuf;
  7810. makestr(&lastsexp,s);
  7811. q = cksplit(1,SEXPMAX,s,NULL,NULL,8,0,0,0); /* Precheck for > 1 SEXP */
  7812. debug(F101,"sexp split","",q->a_size);
  7813. if (q->a_size == 1) { /* We should get exactly one back */
  7814. char * result, * dosexp();
  7815. sexprc = 0; /* Reset out-of-band return code */
  7816. result = dosexp(s); /* Get result */
  7817. debug(F111,"sexp result",result,sexprc);
  7818. if (sexprc == 0) { /* Success */
  7819. /* Echo the result if desired */
  7820. if ((!xcmdsrc && sexpecho != SET_OFF) || sexpecho == SET_ON)
  7821. if (result) if (*result)
  7822. printf(" %s\n",result);
  7823. makestr(&sexpval,result);
  7824. success = sexppv > -1 ? sexppv : 1;
  7825. return(success);
  7826. }
  7827. }
  7828. if (sexprc < 0)
  7829. printf("?Invalid S-Expression: \"%s\"\n",lastsexp);
  7830. return(-9);
  7831. }
  7832. #endif /* NOSEXP */
  7833. #endif /* NOSPL */
  7834. if (cx == XXECH || cx == XXXECH || cx == XXVOID
  7835. #ifndef NOSPL
  7836. || cx == XXAPC
  7837. #endif /* NOSPL */
  7838. ) { /* ECHO or APC */
  7839. if ((x = cmtxt((cx == XXECH || cx == XXXECH) ?
  7840. "Text to be echoed" :
  7841. ((cx == XXVOID) ? "Text" :
  7842. "Application Program Command text"),
  7843. "",
  7844. &s,
  7845. xxstring
  7846. )
  7847. ) < 0)
  7848. return(x);
  7849. if (!s) s = "";
  7850. #ifdef COMMENT
  7851. /* This is to preserve the pre-8.0 behavior but it's too confusing */
  7852. x = strlen(s);
  7853. x = (x > 1) ? ((s[0] == '"' && s[x-1] == '"') ? 1 : 0) : 0;
  7854. #endif /* COMMENT */
  7855. s = brstrip(s); /* Strip braces and doublequotes */
  7856. if (cx == XXECH) { /* ECHO */
  7857. #ifndef NOSPL
  7858. if (!fndiags || fnsuccess) {
  7859. #endif /* NOSPL */
  7860. #ifdef COMMENT
  7861. /* The "if (x)" business preserves previous behavior */
  7862. /* by putting back the doublequotes if they were included. */
  7863. if (x)
  7864. printf("\"%s\"\n",s);
  7865. else
  7866. #endif /* COMMENT */
  7867. printf("%s\n",s);
  7868. #ifndef NOSPL
  7869. }
  7870. #endif /* NOSPL */
  7871. } else if (cx == XXXECH) { /* XECHO */
  7872. if (x)
  7873. printf("\"%s\"",s);
  7874. else
  7875. printf("%s",s);
  7876. #ifdef UNIX
  7877. fflush(stdout);
  7878. #endif /* UNIX */
  7879. } else if (cx == XXAPC) { /* APC */
  7880. #ifdef CK_APC
  7881. if (apcactive == APC_LOCAL ||
  7882. (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH)))
  7883. return(success = 0);
  7884. #endif /* CK_APC */
  7885. if (!local) {
  7886. printf("%c_%s%c\\",ESC,s,ESC);
  7887. #ifdef UNIX
  7888. fflush(stdout);
  7889. #endif /* UNIX */
  7890. } else { /* Local mode - have connection */
  7891. #ifndef NOSPL
  7892. if (ckmakxmsg(tmpbuf, /* Form APC string in buffer */
  7893. TMPBUFSIZ,
  7894. ckctoa((char)ESC),
  7895. ckctoa('_'),
  7896. s,
  7897. ckctoa((char)ESC),
  7898. ckctoa('\\'),
  7899. NULL,NULL,NULL,NULL,NULL,NULL,NULL
  7900. ) > 0)
  7901. return(success = dooutput(tmpbuf, XXOUT));
  7902. printf("?Too long\n");
  7903. return(-9);
  7904. #else
  7905. printf("%c_%s%c\\",ESC,s,ESC);
  7906. #endif /* NOSPL */
  7907. }
  7908. }
  7909. return(success = 1);
  7910. }
  7911. #ifndef NOSPL
  7912. /* Copy macro args from/to two levels up, used internally by _floop et al. */
  7913. if (cx == XXGTA || cx == XXPTA) { /* _GETARGS, _PUTARGS */
  7914. int x;
  7915. debug(F101,"docmd XXGTA","",XXGTA);
  7916. debug(F101,"docmd cx","",cx);
  7917. debug(F101,"docmd XXGTA maclvl","",maclvl);
  7918. x = dogta(cx);
  7919. debug(F101,"docmd dogta returns","",x);
  7920. debug(F101,"docmd dogta maclvl","",maclvl);
  7921. return(x);
  7922. }
  7923. #endif /* NOSPL */
  7924. #ifndef NOSPL
  7925. #ifdef CKCHANNELIO
  7926. if (cx == XXFILE)
  7927. return(dofile(cx));
  7928. else if (cx == XXF_RE || cx == XXF_WR || cx == XXF_OP ||
  7929. cx == XXF_CL || cx == XXF_SE || cx == XXF_RW ||
  7930. cx == XXF_FL || cx == XXF_LI || cx == XXF_ST || cx == XXF_CO)
  7931. return(dofile(cx));
  7932. #endif /* CKCHANNELIO */
  7933. /* ASK, ASKQ, READ */
  7934. if (cx == XXASK || cx == XXASKQ || cx == XXREA ||
  7935. cx == XXRDBL || cx == XXGETC || cx == XXGETK) {
  7936. return(doask(cx));
  7937. }
  7938. #endif /* NOSPL */
  7939. #ifndef NOFRILLS
  7940. #ifndef NOHELP
  7941. if (cx == XXBUG) { /* BUG */
  7942. if ((x = cmcfm()) < 0) return(x);
  7943. return(dobug());
  7944. }
  7945. #endif /* NOHELP */
  7946. #endif /* NOFRILLS */
  7947. #ifndef NOXFER
  7948. if (cx == XXBYE) { /* BYE */
  7949. extern int ftp_cmdlin;
  7950. if ((x = cmcfm()) < 0) return(x);
  7951. #ifdef NEWFTP
  7952. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen())) {
  7953. extern int stayflg, ftp_fai;
  7954. success = ftpbye();
  7955. if (ftp_cmdlin && !stayflg && !local)
  7956. doexit(ftp_fai ? BAD_EXIT : GOOD_EXIT,-1);
  7957. else
  7958. return(success);
  7959. }
  7960. #endif /* NEWFTP */
  7961. if (!local) {
  7962. printf("?No connection - use EXIT to quit.\n");
  7963. return(-9);
  7964. }
  7965. #ifdef CK_XYZ
  7966. if (protocol != PROTO_K) {
  7967. printf("?Sorry, BYE only works with Kermit protocol\n");
  7968. return(-9);
  7969. }
  7970. #endif /* CK_XYZ */
  7971. #ifdef IKS_OPTION
  7972. if (
  7973. #ifdef CK_XYZ
  7974. protocol == PROTO_K &&
  7975. #endif /* CK_XYZ */
  7976. !iks_wait(KERMIT_REQ_START,1)) {
  7977. printf(
  7978. "?A Kermit Server is not available to process this command\n");
  7979. return(-9); /* Correct the return code */
  7980. }
  7981. #endif /* IKS_OPTION */
  7982. bye_active = 1;
  7983. sstate = setgen('L',"","","");
  7984. if (local) ttflui(); /* If local, flush tty input buffer */
  7985. return(0);
  7986. }
  7987. #endif /* NOXFER */
  7988. if (cx == XXBEEP) { /* BEEP */
  7989. int x;
  7990. #ifdef OS2
  7991. int y;
  7992. if ((y = cmkey(beeptab, nbeeptab, "which kind of beep", "information",
  7993. xxstring)) < 0 )
  7994. return (y);
  7995. if ((x = cmcfm()) < 0) return(x);
  7996. bleep((short)y); /* y is one of the BP_ values */
  7997. #else /* OS2 */
  7998. if ((x = cmcfm()) < 0) return(x);
  7999. #ifndef NOSPL
  8000. bleep(BP_NOTE);
  8001. #else
  8002. putchar('\07');
  8003. #endif /* NOSPL */
  8004. #endif /* OS2 */
  8005. return(0);
  8006. }
  8007. #ifndef NOFRILLS
  8008. if (cx == XXCLE) /* CLEAR */
  8009. return(success = doclear());
  8010. #endif /* NOFRILLS */
  8011. if (cx == XXCOM) { /* COMMENT */
  8012. if ((x = cmtxt("Text of comment line","",&s,NULL)) < 0)
  8013. return(x);
  8014. /* Don't change SUCCESS flag for this one */
  8015. return(0);
  8016. }
  8017. #ifndef NOLOCAL
  8018. if (cx == XXCON || cx == XXCQ) /* CONNECT or CONNECT /QUIETLY */
  8019. return(doxconn(cx));
  8020. #endif /* NOLOCAL */
  8021. #ifndef NOFRILLS
  8022. #ifdef ZCOPY
  8023. if (cx == XXCPY) { /* COPY a file */
  8024. #ifdef IKSD
  8025. if (inserver && !ENABLED(en_cpy)) {
  8026. printf("?Sorry, COPY is disabled\n");
  8027. return(-9);
  8028. }
  8029. #endif /* IKSD */
  8030. #ifdef CK_APC
  8031. if (apcactive == APC_LOCAL ||
  8032. (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8033. )
  8034. return(success = 0);
  8035. #endif /* CK_APC */
  8036. return(docopy());
  8037. }
  8038. #endif /* ZCOPY */
  8039. #ifdef NT
  8040. if ( cx == XXLINK ) {
  8041. #ifdef IKSD
  8042. if (inserver && !ENABLED(en_cpy)) {
  8043. printf("?Sorry, LINK (COPY) is disabled\n");
  8044. return(-9);
  8045. }
  8046. #endif /* IKSD */
  8047. #ifdef CK_APC
  8048. if (apcactive == APC_LOCAL ||
  8049. (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  8050. )
  8051. return(success = 0);
  8052. #endif /* CK_APC */
  8053. return(dolink());
  8054. }
  8055. #endif /* NT */
  8056. #endif /* NOFRILLS */
  8057. /* CD and friends */
  8058. if (cx == XXCWD || cx == XXCDUP || cx == XXBACK ||
  8059. cx == XXLCWD || cx == XXLCDU || cx == XXKCD) {
  8060. #ifdef LOCUS
  8061. if (!locus) {
  8062. if (cx == XXCWD) {
  8063. #ifdef NOXFER
  8064. return(-2);
  8065. #else
  8066. return(dormt(XZCWD));
  8067. #endif /* NOXFER */
  8068. } else if (cx == XXCDUP) {
  8069. #ifdef NOXFER
  8070. return(-2);
  8071. #else
  8072. return(dormt(XZCDU));
  8073. #endif /* NOXFER */
  8074. }
  8075. }
  8076. #endif /* LOCUS */
  8077. #ifdef IKSD
  8078. if (inserver && !ENABLED(en_cwd)) {
  8079. printf("?Sorry, changing directories is disabled\n");
  8080. return(-9);
  8081. }
  8082. #endif /* IKSD */
  8083. return(success = docd(cx));
  8084. }
  8085. if (cx == XXCHK) /* CHECK */
  8086. return(success = dochk());
  8087. if (cx == XXCLO) { /* CLOSE */
  8088. x = cmkey(clstab,ncls,"\"CONNECTION\", or log or file to close",
  8089. "connection",xxstring);
  8090. if (x == -3) {
  8091. printf("?You must say which file or log\n");
  8092. return(-9);
  8093. }
  8094. if (x < 0) return(x);
  8095. if ((y = cmcfm()) < 0) return(y);
  8096. #ifndef NOLOCAL
  8097. if (x == 9999) { /* CLOSE CONNECTION */
  8098. x = clsconnx(0);
  8099. switch (x) {
  8100. case 0:
  8101. if (msgflg) printf("?Connection was not open\n");
  8102. case -1:
  8103. return(0);
  8104. case 1:
  8105. whyclosed = WC_CLOS;
  8106. return(1);
  8107. }
  8108. return(0);
  8109. }
  8110. #endif /* NOLOCAL */
  8111. y = doclslog(x);
  8112. success = (y == 1);
  8113. return(success);
  8114. }
  8115. #ifndef NOSPL
  8116. if (cx == XXDCL || cx == XXUNDCL) { /* DECLARE an array */
  8117. return(dodcl(cx));
  8118. }
  8119. #endif /* NOSPL */
  8120. #ifndef NODIAL
  8121. if (cx == XXRED || cx == XXDIAL || cx == XXPDIA ||
  8122. cx == XXANSW || cx == XXLOOK) { /* DIAL, REDIAL etc */
  8123. #ifdef VMS
  8124. extern int batch;
  8125. #else
  8126. #ifdef UNIXOROSK
  8127. extern int backgrd;
  8128. #endif /* UNIXOROSK */
  8129. #endif /* VMS */
  8130. x = dodial(cx);
  8131. debug(F101,"dodial returns","",x);
  8132. if ((cx == XXDIAL || cx == XXRED || cx == XXANSW) &&
  8133. (x > 0) && /* If DIAL or REDIAL succeeded */
  8134. (dialsta != DIA_PART) && /* and it wasn't partial */
  8135. (dialcon > 0)) {
  8136. if ((dialcon == 1 || /* And DIAL CONNECT is ON, */
  8137. ((dialcon == 2) && /* or DIAL CONNECT is AUTO */
  8138. !xcmdsrc /* and we're at top level... */
  8139. #ifdef VMS
  8140. && !batch /* Not if running from batch */
  8141. #else
  8142. #ifdef UNIXOROSK
  8143. && !backgrd /* Not if running in background */
  8144. #endif /* UNIXOROSK */
  8145. #endif /* VMS */
  8146. ))) /* Or AUTO */
  8147. x = doconect(dialcq, /* Then also CONNECT */
  8148. cmdlvl == 0 ? 1 : 0
  8149. );
  8150. if (ttchk() < 0)
  8151. dologend();
  8152. }
  8153. return(success = x);
  8154. }
  8155. #endif /* NODIAL */
  8156. #ifndef NOPUSH
  8157. #ifdef CK_REXX
  8158. if (cx == XXREXX) { /* REXX */
  8159. extern int nopush;
  8160. if ( nopush )
  8161. return(success=0);
  8162. return(dorexx());
  8163. }
  8164. #endif /* CK_REXX */
  8165. #endif /* NOPUSH */
  8166. #ifndef NOFRILLS
  8167. if (cx == XXDEL || cx == XXLDEL) { /* DELETE */
  8168. #ifdef LOCUS
  8169. if (!locus && cx != XXLDEL) {
  8170. #ifdef NOXFER
  8171. return(-2);
  8172. #else
  8173. return(dormt(XZDEL));
  8174. #endif /* NOXFER */
  8175. }
  8176. #endif /* LOCUS */
  8177. #ifdef IKSD
  8178. if (inserver && (!ENABLED(en_del)
  8179. #ifdef CK_LOGIN
  8180. || isguest
  8181. #endif /* CK_LOGIN */
  8182. )) {
  8183. printf("?Sorry, DELETE is disabled\n");
  8184. return(-9);
  8185. }
  8186. #endif /* IKSD */
  8187. #ifdef CK_APC
  8188. if ((apcactive == APC_LOCAL) ||
  8189. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8190. return(success = 0);
  8191. #endif /* CK_APC */
  8192. return(dodel());
  8193. }
  8194. #endif /* NOFRILLS */
  8195. if (cx == XXTOUC) /* TOUCH */
  8196. return(dodir(cx));
  8197. if (cx == XXCHG) /* CHANGE */
  8198. return(dodir(cx));
  8199. /* DIRECTORY commands */
  8200. if (cx == XXDIR || cx == XXLS || cx == XXLDIR ||
  8201. cx == XXWDIR || cx == XXHDIR) {
  8202. #ifdef LOCUS
  8203. if (!locus && cx != XXLDIR) {
  8204. #ifdef NOXFER
  8205. return(-2);
  8206. #else
  8207. return(dormt(XZDIR));
  8208. #endif /* NOXFER */
  8209. }
  8210. #endif /* LOCUS */
  8211. #ifdef IKSD
  8212. if (inserver && !ENABLED(en_dir)) {
  8213. printf("?Sorry, DIRECTORY is disabled\n");
  8214. return(-9);
  8215. }
  8216. #endif /* IKSD */
  8217. return(dodir(cx));
  8218. }
  8219. #ifndef NOSPL
  8220. if (cx == XXELS) /* ELSE */
  8221. return(doelse());
  8222. #endif /* NOSPL */
  8223. #ifndef NOSERVER
  8224. #ifndef NOFRILLS
  8225. if (cx == XXENA || cx == XXDIS) { /* ENABLE, DISABLE */
  8226. s = (cx == XXENA) ?
  8227. "Server function to enable" :
  8228. "Server function to disable";
  8229. if ((x = cmkey(enatab,nena,s,"",xxstring)) < 0) {
  8230. if (x == -3) {
  8231. printf("?Name of server function required\n");
  8232. return(-9);
  8233. } else return(x);
  8234. }
  8235. if ((y = cmkey(kmstab,3,"mode","both",xxstring)) < 0) {
  8236. if (y == -3) {
  8237. printf("?Please specify remote, local, or both\n");
  8238. return(-9);
  8239. } else return(y);
  8240. }
  8241. if (cx == XXDIS) /* Disabling, not enabling */
  8242. y = 3 - y;
  8243. if ((z = cmcfm()) < 0) return(z);
  8244. #ifdef CK_APC
  8245. if ((apcactive == APC_LOCAL) ||
  8246. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8247. return(success = 0);
  8248. #endif /* CK_APC */
  8249. #ifdef IKSD
  8250. /* This may seem like it duplicates the work in doenable() */
  8251. /* but this code returns failure whereas doenable() returns */
  8252. /* success. */
  8253. if (inserver &&
  8254. #ifdef IKSDCONF
  8255. iksdcf &&
  8256. #endif /* IKSDCONF */
  8257. (x == EN_HOS || x == EN_PRI || x == EN_MAI || x == EN_WHO ||
  8258. isguest))
  8259. return(success = 0);
  8260. #endif /* IKSD */
  8261. return(doenable(y,x));
  8262. }
  8263. #endif /* NOFRILLS */
  8264. #endif /* NOSERVER */
  8265. #ifndef NOSPL
  8266. if (cx == XXRET) { /* RETURN */
  8267. if ((x = cmtxt("Optional return value","",&s,NULL)) < 0)
  8268. return(x);
  8269. s = brstrip(s); /* Strip braces */
  8270. if (cmdlvl == 0) /* At top level, nothing happens... */
  8271. return(success = 1);
  8272. switch (cmdstk[cmdlvl].src) { /* Action depends on command source */
  8273. case CMD_TF: /* Command file */
  8274. popclvl(); /* Pop command level */
  8275. return(success = 1); /* always succeeds */
  8276. case CMD_MD: /* Macro */
  8277. case CMD_KB: /* Prompt */
  8278. return(doreturn(s)); /* Trailing text is return value. */
  8279. default: /* Shouldn't happen */
  8280. return(-2);
  8281. }
  8282. }
  8283. #endif /* NOSPL */
  8284. #ifndef NOSPL
  8285. if (cx == XXOPE) /* OPEN */
  8286. return(doopen());
  8287. #endif /* NOSPL */
  8288. #ifndef NOSPL
  8289. if (cx == XXOUT || cx == XXLNOUT) { /* OUTPUT or LINEOUT */
  8290. if ((x = cmtxt("Text to be output","",&s,NULL)) < 0)
  8291. return(x);
  8292. #ifdef CK_APC
  8293. if ((apcactive == APC_LOCAL) ||
  8294. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8295. return(success = 0);
  8296. #endif /* CK_APC */
  8297. debug(F110,"OUTPUT 1",s,0);
  8298. s = brstrip(s); /* Strip enclosing braces, */
  8299. debug(F110,"OUTPUT 2",s,0);
  8300. /*
  8301. I don't think I could ever fully explain this in a million years...
  8302. We have read the user's string without calling the variable-expander
  8303. function. Now, before we call it, we have to double backslashes that
  8304. appear before \N, \B, \L, and \ itself, so the expander function will
  8305. reduce them back to single backslashes, so when we call dooutput()...
  8306. But it's more complicated than that.
  8307. */
  8308. if (cmdgquo()) { /* Only if COMMAND QUOTING ON ... */
  8309. for (x = 0, y = 0; s[x]; x++, y++) {
  8310. if (s[x] == CMDQ) {
  8311. char c = s[x+1];
  8312. if (c == 'n' || c == 'N' ||
  8313. c == 'b' || c == 'B' ||
  8314. c == 'l' || c == 'L' ||
  8315. c == CMDQ)
  8316. line[y++] = CMDQ;
  8317. }
  8318. line[y] = s[x];
  8319. }
  8320. line[y++] = '\0'; /* Now expand variables, etc. */
  8321. debug(F110,"OUTPUT 3",line,0);
  8322. s = line+y+1;
  8323. x = LINBUFSIZ - (int) strlen(line) - 1;
  8324. debug(F101,"OUTPUT size","",x);
  8325. if (zzstring(line,&s,&x) < 0)
  8326. return(success = 0);
  8327. s = line+y+1;
  8328. debug(F110,"OUTPUT 4",s,0);
  8329. }
  8330. success = dooutput(s,cx);
  8331. return(success);
  8332. }
  8333. #endif /* NOSPL */
  8334. #ifdef ANYX25
  8335. #ifndef IBMX25
  8336. if (cx == XXPAD) { /* PAD commands */
  8337. x = cmkey(padtab,npadc,"PAD command","",xxstring);
  8338. if (x == -3) {
  8339. printf("?You must specify a PAD command to execute\n");
  8340. return(-9);
  8341. }
  8342. if (x < 0) return(x);
  8343. switch (x) {
  8344. case XYPADL:
  8345. if (x25stat() < 0)
  8346. printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8347. else {
  8348. x25clear();
  8349. initpad();
  8350. }
  8351. break;
  8352. case XYPADS:
  8353. if (x25stat() < 0)
  8354. printf("Not connected\r\n");
  8355. else {
  8356. extern int linkid, lcn;
  8357. conol("Connected thru ");
  8358. conol(ttname);
  8359. printf(", Link id %d, Logical channel number %d\r\n",
  8360. linkid,lcn);
  8361. }
  8362. break;
  8363. case XYPADR:
  8364. if (x25stat() < 0)
  8365. printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8366. else
  8367. x25reset(0,0);
  8368. break;
  8369. case XYPADI:
  8370. if (x25stat() < 0)
  8371. printf("Sorry, you must 'set network' & 'set host' first\r\n");
  8372. else
  8373. x25intr(0);
  8374. }
  8375. return(0);
  8376. }
  8377. #endif /* IBMX25 */
  8378. #endif /* ANYX25 */
  8379. #ifndef NOSPL
  8380. if (cx == XXPAU || cx == XXWAI || cx == XXMSL) /* PAUSE, WAIT, etc */
  8381. return(dopaus(cx));
  8382. #endif /* NOSPL */
  8383. #ifndef NOFRILLS
  8384. if (cx == XXPRI) {
  8385. #ifdef IKSD
  8386. #ifdef CK_LOGIN
  8387. if (inserver && (isguest || !ENABLED(en_pri))) {
  8388. printf("?Sorry, printing is disabled\n");
  8389. return(-9);
  8390. }
  8391. #endif /* CK_LOGIN */
  8392. #endif /* IKSD */
  8393. if ((x = cmifi("File to print","",&s,&y,xxstring)) < 0) {
  8394. if (x == -3) {
  8395. printf("?A file specification is required\n");
  8396. return(-9);
  8397. } else return(x);
  8398. }
  8399. if (y != 0) {
  8400. printf("?Wildcards not allowed\n");
  8401. return(-9);
  8402. }
  8403. ckstrncpy(line,s,LINBUFSIZ);
  8404. s = "";
  8405. #ifndef NT
  8406. if ((x = cmtxt("Local print command options, or carriage return","",&s,
  8407. xxstring)) < 0)
  8408. return(x);
  8409. #endif /* NT */
  8410. if ((x = cmcfm()) < 0)
  8411. return(x);
  8412. return(success = (zprint(s,line) == 0) ? 1 : 0);
  8413. }
  8414. #endif /* NOFRILLS */
  8415. #ifdef TCPSOCKET
  8416. #ifndef NOPUSH
  8417. if (cx == XXPNG) /* PING an IP host */
  8418. return(doping());
  8419. #endif /* NOPUSH */
  8420. #ifndef NOFTP
  8421. if (cx == XXFTP) /* FTP */
  8422. #ifdef SYSFTP
  8423. #ifndef NOPUSH
  8424. return(doftp()); /* Just runs system's ftp program */
  8425. #else
  8426. return(-2);
  8427. #endif /* NOPUSH */
  8428. #else
  8429. return(doxftp());
  8430. #endif /* SYSFTP */
  8431. #endif /* NOFTP */
  8432. #endif /* TCPSOCKET */
  8433. if (cx == XXPWD || cx == XXLPWD) { /* PWD */
  8434. #ifdef OS2
  8435. char *pwp;
  8436. #endif /* OS2 */
  8437. if ((x = cmcfm()) < 0)
  8438. return(x);
  8439. #ifdef LOCUS
  8440. if (!locus && cx != XXLPWD) {
  8441. #ifdef NOXFER
  8442. return(-2);
  8443. #else
  8444. return(dormt(XZPWD));
  8445. #endif /* NOXFER */
  8446. }
  8447. #endif /* LOCUS */
  8448. #ifndef MAC
  8449. #ifndef OS2
  8450. #ifdef UNIX
  8451. printf("%s\n",zgtdir());
  8452. #else
  8453. xsystem(PWDCMD);
  8454. #endif /* UNIX */
  8455. return(success = 1); /* Blind faith */
  8456. #else /* OS2 */
  8457. if (pwp = zgtdir()) {
  8458. if (*pwp) {
  8459. #ifdef NT
  8460. line[0] = NUL;
  8461. ckGetLongPathName(pwp,line,LINBUFSIZ);
  8462. line[LINBUFSIZ-1] = NUL;
  8463. tmpbuf[0] = NUL;
  8464. GetShortPathName(pwp,tmpbuf,TMPBUFSIZ);
  8465. tmpbuf[TMPBUFSIZ-1] = NUL;
  8466. pwp = line;
  8467. if (!strcmp(line,tmpbuf)) {
  8468. #endif /* NT */
  8469. printf("%s\n",pwp);
  8470. #ifdef NT
  8471. } else {
  8472. printf(" Long name: %s\n",line);
  8473. printf(" Short name: %s\n",tmpbuf);
  8474. }
  8475. #endif /* NT */
  8476. }
  8477. return(success = ((int)strlen(pwp) > 0));
  8478. } else return(success = 0);
  8479. #endif /* OS2 */
  8480. #else /* MAC */
  8481. if (pwp = zgtdir()) {
  8482. printf("%s\n",pwp);
  8483. return(success = ((int)strlen(pwp) > 0));
  8484. } else return(success = 0);
  8485. #endif /* MAC */
  8486. }
  8487. if (cx == XXQUI || cx == XXEXI) { /* EXIT, QUIT */
  8488. extern int quitting;
  8489. if ((y = cmnum("exit status code",ckitoa(xitsta),10,&x,xxstring)) < 0)
  8490. return(y);
  8491. if ((y = cmtxt("Optional EXIT message","",&s,xxstring)) < 0)
  8492. return(y);
  8493. s = brstrip(s);
  8494. ckstrncpy(line,s,LINBUFSIZ);
  8495. if (!hupok(0)) /* Check if connection still open */
  8496. return(success = 0);
  8497. if (line[0]) { /* Print EXIT message if given */
  8498. extern int exitmsg;
  8499. switch (exitmsg) {
  8500. case 0: break;
  8501. case 1: printf("%s\n",(char *)line); break;
  8502. case 2: fprintf(stderr,"%s\n",(char *)line); break;
  8503. }
  8504. }
  8505. quitting = 1; /* Flag that we are quitting. */
  8506. #ifdef VMS
  8507. doexit(GOOD_EXIT,x);
  8508. #else
  8509. #ifdef OSK
  8510. /* Returning any codes here makes the OS-9 shell print an error message. */
  8511. doexit(GOOD_EXIT,-1);
  8512. #else
  8513. #ifdef datageneral
  8514. doexit(GOOD_EXIT,x);
  8515. #else
  8516. doexit(x,-1);
  8517. #endif /* datageneral */
  8518. #endif /* OSK */
  8519. #endif /* VMS */
  8520. }
  8521. #ifndef NOXFER
  8522. #ifndef NOFRILLS
  8523. if (cx == XXERR) { /* ERROR */
  8524. #ifdef CK_XYZ
  8525. if (protocol != PROTO_K) {
  8526. printf("Sorry, E-PACKET only works with Kermit protocol\n");
  8527. return(-9);
  8528. }
  8529. #endif /* CK_XYZ */
  8530. if ((x = cmcfm()) < 0) return(x);
  8531. ttflui();
  8532. epktflg = 1;
  8533. sstate = 'a';
  8534. return(0);
  8535. }
  8536. #endif /* NOFRILLS */
  8537. if (cx == XXFIN) { /* FINISH */
  8538. #ifdef NEWFTP
  8539. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8540. return(ftpbye());
  8541. #endif /* NEWFTP */
  8542. #ifdef CK_XYZ
  8543. if (protocol != PROTO_K) {
  8544. printf("Sorry, FINISH only works with Kermit protocol\n");
  8545. return(-9);
  8546. }
  8547. #endif /* CK_XYZ */
  8548. if ((x = cmcfm()) < 0) return(x);
  8549. #ifdef IKS_OPTION
  8550. if (
  8551. #ifdef CK_XYZ
  8552. protocol == PROTO_K &&
  8553. #endif /* CK_XYZ */
  8554. !iks_wait(KERMIT_REQ_START,1)) {
  8555. printf(
  8556. "?A Kermit Server is not available to process this command\n");
  8557. return(-9); /* Correct the return code */
  8558. }
  8559. #endif /* IKS_OPTION */
  8560. sstate = setgen('F',"","","");
  8561. if (local) ttflui(); /* If local, flush tty input buffer */
  8562. return(0);
  8563. }
  8564. #endif /* NOXFER */
  8565. #ifndef NOSPL
  8566. if (cx == XXFOR) /* FOR loop */
  8567. return(dofor());
  8568. #endif /* NOSPL */
  8569. #ifndef NOXFER
  8570. /* GET MGET REGET RETRIEVE etc */
  8571. if (cx == XXGET || cx == XXMGET || cx == XXREGET || cx == XXRETR) {
  8572. #ifdef IKSD
  8573. if (inserver && !ENABLED(en_sen)) {
  8574. printf("?Sorry, reception of files is disabled\n");
  8575. return(-9);
  8576. }
  8577. #endif /* IKSD */
  8578. return(doxget(cx));
  8579. }
  8580. #endif /* NOXFER */
  8581. #ifndef NOSPL
  8582. #ifndef NOFRILLS
  8583. if (cx == XXGOK) { /* GETOK */
  8584. return(success = doask(cx));
  8585. }
  8586. #endif /* NOFRILLS */
  8587. #endif /* NOSPL */
  8588. if (cx == XXHLP) { /* HELP */
  8589. #ifdef NOHELP
  8590. return(dohlp(XXHLP));
  8591. #else
  8592. x = cmkey2(cmdtab,
  8593. ncmd,"\nCommand or topic","help",toktab,xxstring,1+2+8);
  8594. debug(F111,"HELP command x",cmdbuf,x);
  8595. if (x == -5) {
  8596. y = chktok(toktab);
  8597. debug(F101,"HELP cmkey token","",y);
  8598. /* ungword(); */
  8599. switch (y) {
  8600. #ifndef NOPUSH
  8601. case '!':
  8602. case '@': x = XXSHE; break;
  8603. case '<': x = XXFUN; break;
  8604. #endif /* NOPUSH */
  8605. case '#': x = XXCOM; break;
  8606. case ';': x = XXCOM; break;
  8607. #ifndef NOSPL
  8608. case '.': x = XXDEF; break;
  8609. case ':': x = XXLBL; break;
  8610. #ifndef NOSEXP
  8611. case '(': x = XXSEXP; break;
  8612. #endif /* NOSEXP */
  8613. #endif /* NOSPL */
  8614. #ifdef CK_RECALL
  8615. case '^': x = XXREDO; break;
  8616. #endif /* CK_RECALL */
  8617. default:
  8618. printf("\n?Not a valid command or token - %s\n",cmdbuf);
  8619. x = -2;
  8620. }
  8621. }
  8622. makestr(&hlptok,atmbuf);
  8623. debug(F111,"HELP token",hlptok,x);
  8624. return(dohlp(x));
  8625. #endif /* NOHELP */
  8626. }
  8627. #ifndef NOHELP
  8628. if (cx == XXINT) /* INTRO */
  8629. return(hmsga(introtxt));
  8630. if (cx == XXNEW) { /* NEWS */
  8631. int x;
  8632. extern char * k_info_dir;
  8633. x = hmsga(newstxt);
  8634. return(x);
  8635. }
  8636. #ifdef OS2ONLY
  8637. if (cx == XXUPD) { /* View UPDATE file */
  8638. extern char exedir[];
  8639. char * pTopic;
  8640. char updstr[2048];
  8641. if ((x = cmtxt("topic name","",&pTopic,xxstring)) < 0)
  8642. return x;
  8643. #ifdef COMMENT
  8644. sprintf(updstr,
  8645. "start view %s\\docs\\k2.inf+%s\\docs\\using_ck.inf+\
  8646. %s\\docs\\dialing.inf+%s\\docs\\modems.inf %s",
  8647. exedir,exedir,exedir,exedir,pTopic
  8648. );
  8649. #else
  8650. if (ckmakxmsg(updstr,
  8651. 2048,
  8652. "start view ",
  8653. exedir,
  8654. "\\docs\\k2.inf+",
  8655. exedir,
  8656. "\\docs\\using_ck.inf+",
  8657. exedir,
  8658. "\\docs\\dialing.inf+",
  8659. exedir,
  8660. "\\docs\\modems.inf ",
  8661. pTopic,
  8662. NULL,
  8663. NULL
  8664. ) > 0)
  8665. #endif /* COMMENT */
  8666. system(updstr);
  8667. return(success = 1);
  8668. }
  8669. #endif /* OS2ONLY */
  8670. #endif /* NOHELP */
  8671. #ifndef NOLOCAL
  8672. if (cx == XXHAN) { /* HANGUP */
  8673. if ((x = cmcfm()) < 0) return(x);
  8674. #ifdef NEWFTP
  8675. if ((ftpget == 1) || ((ftpget == 2) && !local && ftpisopen()))
  8676. return(success = ftpbye());
  8677. #endif /* NEWFTP */
  8678. #ifndef NODIAL
  8679. if ((x = mdmhup()) < 1) {
  8680. debug(F101,"HANGUP mdmup","",x);
  8681. #endif /* NODIAL */
  8682. x = tthang();
  8683. debug(F101,"HANGUP tthang","",x);
  8684. x = (x > -1);
  8685. #ifndef NODIAL
  8686. }
  8687. dialsta = DIA_UNK;
  8688. #endif /* NODIAL */
  8689. whyclosed = WC_CLOS;
  8690. ttchk(); /* In case of CLOSE-ON-DISCONNECT */
  8691. dologend();
  8692. #ifdef OS2
  8693. if (x)
  8694. DialerSend(OPT_KERMIT_HANGUP, 0);
  8695. #endif /* OS2 */
  8696. if (x) haveline = 0;
  8697. return(success = x);
  8698. }
  8699. #endif /* NOLOCAL */
  8700. #ifndef NOSPL
  8701. /* INPUT, REINPUT, and MINPUT */
  8702. if (cx == XXINP || cx == XXREI || cx == XXMINP) {
  8703. long zz;
  8704. int flags = 0, incount = 0;
  8705. extern int itsapattern, isjoin, isinbuflen;
  8706. int c, getval;
  8707. struct FDB sw, nu, fl;
  8708. int fc, havetime = 0;
  8709. char * m;
  8710. if (cx == XXREI) {
  8711. m = "Timeout in seconds (ignored)";
  8712. } else {
  8713. m = "Seconds to wait for input,\n or time of day hh:mm:ss,\
  8714. or switch";
  8715. }
  8716. cmfdbi(&sw, /* First FDB - command switches */
  8717. _CMKEY, /* fcode */
  8718. m, /* helpmsg */
  8719. ckitoa(indef), /* default */
  8720. "", /* addtl string data */
  8721. ninputsw, /* addtl numeric data 1: tbl size */
  8722. 4, /* addtl numeric data 2: 4 = cmswi */
  8723. xxstring, /* Processing function */
  8724. inputsw, /* Keyword table */
  8725. &nu /* Pointer to next FDB */
  8726. );
  8727. cmfdbi(&nu,
  8728. _CMNUM, /* Number */
  8729. m, /* Help message */
  8730. ckitoa(indef), /* default */
  8731. "", /* N/A */
  8732. 10, /* Radix = 10 */
  8733. 0, /* N/A */
  8734. xxstring, /* Processing function */
  8735. NULL, /* N/A */
  8736. &fl /* Next */
  8737. );
  8738. cmfdbi(&fl, /* Time of day hh:mm:ss */
  8739. _CMFLD, /* fcode */
  8740. "", /* hlpmsg */
  8741. "",
  8742. "", /* addtl string data */
  8743. 0, /* addtl numeric data 1 */
  8744. 0, /* addtl numeric data 2 */
  8745. xxstring,
  8746. NULL,
  8747. NULL
  8748. );
  8749. fc = (cx == XXREI) ? cmfdb(&nu) : cmfdb(&sw); /* Parse something */
  8750. for (y = 0; y < MINPMAX; y++) { /* Initialize search strings */
  8751. mp[y] = 0; /* Assume it's not a pattern */
  8752. if (!mpinited) {
  8753. ms[y] = NULL;
  8754. }
  8755. if (ms[y]) {
  8756. free(ms[y]); /* Free old strings, if any */
  8757. ms[y] = NULL;
  8758. }
  8759. }
  8760. mpinited = 1;
  8761. while (!havetime) {
  8762. if (fc < 0) { /* Error */
  8763. if (fc == -3) {
  8764. printf("?Syntax error in INPUT-class command\n");
  8765. return(-9);
  8766. } else
  8767. return(fc);
  8768. }
  8769. switch (cmresult.fcode) {
  8770. case _CMKEY: /* Switch */
  8771. c = cmgbrk();
  8772. if ((getval = (c == ':' || c == '=')) &&
  8773. !(cmgkwflgs() & CM_ARG)) {
  8774. printf("?This switch does not take an argument\n");
  8775. return(-9);
  8776. }
  8777. if (getval && cmresult.nresult == INPSW_COU) {
  8778. if ((y = cmnum("Number of bytes to read",
  8779. "",10,&x,xxstring)) < 0)
  8780. return(y);
  8781. incount = x;
  8782. }
  8783. flags |= cmresult.nresult;
  8784. fc = cmfdb(&sw); /* Maybe parse more switches */
  8785. continue;
  8786. case _CMNUM: /* Seconds to time out */
  8787. x = cmresult.nresult;
  8788. #ifdef CKFLOAT
  8789. if (inscale != 1.0) /* Scale */
  8790. x *= inscale;
  8791. #endif /* CKFLOAT */
  8792. havetime++;
  8793. break;
  8794. case _CMFLD:
  8795. zz = tod2sec(atmbuf); /* Convert to secs since midnight */
  8796. if (zz < 0L) {
  8797. printf("?Number, expression, or time of day required\n");
  8798. return(-9);
  8799. } else {
  8800. char now[32]; /* Current time */
  8801. char *p;
  8802. long tnow;
  8803. p = now;
  8804. ztime(&p);
  8805. tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  8806. if (zz < tnow) /* User's time before now */
  8807. zz += 86400L; /* So make it tomorrow */
  8808. zz -= tnow; /* Seconds from now. */
  8809. if (zz > -1L) {
  8810. x = zz;
  8811. if (zz != (long) x) {
  8812. printf(
  8813. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  8814. );
  8815. return(-9);
  8816. }
  8817. }
  8818. havetime++;
  8819. }
  8820. break;
  8821. default:
  8822. printf("?Internal error\n");
  8823. return(-9);
  8824. }
  8825. }
  8826. /* Now parse the search text */
  8827. #ifdef CK_MINPUT
  8828. if (cx == XXMINP) { /* MINPUT */
  8829. int i, k = 0, n = 0;
  8830. struct stringarray * q;
  8831. keepallchars = 1;
  8832. while (k < MINPMAX) {
  8833. if ((y = cmfld("String or pattern","",&s,xxstring)) < 0) {
  8834. if (y == -3) {
  8835. if ((y = cmcfm()) < 0)
  8836. return(y);
  8837. break;
  8838. } else {
  8839. return(y);
  8840. }
  8841. }
  8842. debug(F111,"MINPUT field",s,k);
  8843. if (isjoin) {
  8844. if ((q = cksplit(1,0,s," ",(char *)c1chars,3,0,0,0))) {
  8845. char ** ap = q->a_head;
  8846. n = q->a_size;
  8847. debug(F101,"minput cksplit size","",n);
  8848. for (i = 1; i <= n && k < MINPMAX; i++) {
  8849. if (!ap[i]) /* Add non-empty elements */
  8850. continue;
  8851. if (!*(ap[i]))
  8852. continue;
  8853. makestr(&(ms[k]),ap[i]);
  8854. debug(F111,"MINPUT JOIN",ms[k],k);
  8855. k++;
  8856. }
  8857. }
  8858. } else {
  8859. if (s) if (*s) {
  8860. makestr(&(ms[k]),brstrip(s));
  8861. if (itsapattern) mp[k] = 1;
  8862. debug(F111,"MINPUT",ms[k],itsapattern);
  8863. k++;
  8864. }
  8865. }
  8866. }
  8867. keepallchars = 0;
  8868. } else {
  8869. #endif /* CK_MINPUT */
  8870. /* INPUT or REINPUT */
  8871. if (flags & INPSW_COU) {
  8872. if ((y = cmcfm()) < 0)
  8873. return(y);
  8874. } else {
  8875. if ((y = cmtxt("Material to be input","",&s,xxstring)) < 0)
  8876. return(y);
  8877. }
  8878. mp[0] = itsapattern ? 1 : 0;
  8879. makestr(&(ms[0]),brstrip(s));
  8880. ms[1] = NULL;
  8881. #ifdef CK_MINPUT
  8882. }
  8883. #endif /* CK_MINPUT */
  8884. if (incount > 0) /* No searching if /COUNT: given */
  8885. makestr(&(ms[0]),NULL);
  8886. if (cx == XXINP || cx == XXMINP) { /* Not REINPUT... */
  8887. i_active = 1;
  8888. /* Go try to input the search string */
  8889. success = doinput(x,ms,mp,flags,incount);
  8890. i_active = 0;
  8891. } else { /* REINPUT */
  8892. success = doreinp(x,ms[0],itsapattern);
  8893. }
  8894. if (intime[cmdlvl] && !success) { /* TIMEOUT-ACTION = QUIT? */
  8895. popclvl(); /* If so, pop command level. */
  8896. if (pflag && cmdlvl == 0) {
  8897. if (cx == XXINP) printf("?INPUT timed out\n");
  8898. if (cx == XXMINP) printf("?MINPUT timed out\n");
  8899. if (cx == XXREI) printf("?REINPUT failed\n");
  8900. }
  8901. }
  8902. return(success); /* Return do(re)input's return code */
  8903. }
  8904. #endif /* NOSPL */
  8905. if (cx == XXLOG) { /* LOG */
  8906. x = cmkey(logtab,nlog,"What to log","",xxstring);
  8907. if (x == -3) {
  8908. printf("?Type of log required\n");
  8909. return(-9);
  8910. }
  8911. if (x < 0) return(x);
  8912. x = dolog(x);
  8913. if (x < 0)
  8914. return(x);
  8915. else
  8916. return(success = x);
  8917. }
  8918. if (cx == XXLOGIN) { /* (REMOTE) LOGIN */
  8919. #ifdef NEWFTP
  8920. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8921. return(success = doftpusr());
  8922. #endif /* NEWFTP */
  8923. #ifdef IKSD
  8924. if (inserver) {
  8925. printf("?Already logged in\n");
  8926. return(-9);
  8927. } else
  8928. #endif /* IKSD */
  8929. {
  8930. #ifdef NOXFER
  8931. return(-2);
  8932. #else
  8933. return(dormt(XZLGI));
  8934. #endif /* NOXFER */
  8935. }
  8936. }
  8937. if (cx == XXLOGOUT) { /* (REMOTE) LOGOUT */
  8938. #ifdef NEWFTP
  8939. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8940. return(success = doftpres());
  8941. #endif /* NEWFTP */
  8942. #ifdef IKSD
  8943. if (inserver) {
  8944. if ((x = cmcfm()) < 0)
  8945. return(x);
  8946. doexit(GOOD_EXIT,xitsta);
  8947. } else
  8948. #endif /* IKSD */
  8949. if (!local || (network && ttchk() < 0)) {
  8950. printf("?No connection.\n");
  8951. return(-9);
  8952. } else {
  8953. #ifdef NOXFER
  8954. return(-2);
  8955. #else
  8956. return(dormt(XZLGO));
  8957. #endif /* NOXFER */
  8958. }
  8959. }
  8960. #ifndef NOSCRIPT
  8961. if (cx == XXLOGI) { /* UUCP-style script */
  8962. if ((x = cmtxt("expect-send expect-send ...","",&s,xxstring)) < 0)
  8963. return(x);
  8964. #ifdef CK_APC
  8965. if ((apcactive == APC_LOCAL) ||
  8966. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  8967. return(success = 0);
  8968. #endif /* CK_APC */
  8969. #ifdef VMS
  8970. conres(); /* For Ctrl-C to work... */
  8971. #endif /* VMS */
  8972. return(success = dologin(s)); /* Return 1=completed, 0=failed */
  8973. }
  8974. #endif /* NOSCRIPT */
  8975. #ifndef NOXFER
  8976. #ifdef PIPESEND
  8977. if (cx == XXCREC) { /* CRECEIVE */
  8978. if (protocol != PROTO_K) {
  8979. printf("?Sorry, CRECEIVE works only with Kermit protocol\n");
  8980. return(-9);
  8981. } else
  8982. return(doxget(cx));
  8983. }
  8984. if (cx == XXCGET) { /* CGET */
  8985. return(doxget(cx));
  8986. }
  8987. #endif /* PIPESEND */
  8988. if (cx == XXREC) /* RECEIVE */
  8989. return(doxget(cx));
  8990. #endif /* NOXFER */
  8991. #ifndef NOXFER
  8992. if (cx == XXREM) { /* REMOTE */
  8993. #ifdef NEWFTP
  8994. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  8995. return(doftprmt(0,0));
  8996. #endif /* NEWFTP */
  8997. #ifdef CK_XYZ
  8998. if (protocol != PROTO_K) {
  8999. printf("Sorry, REMOTE commands only work with Kermit protocol\n");
  9000. return(-9);
  9001. }
  9002. #endif /* CK_XYZ */
  9003. x = cmkey(remcmd,nrmt,"Remote Kermit server command","",xxstring);
  9004. if (x == -3) {
  9005. printf("?You must specify a command for the remote server\n");
  9006. return(-9);
  9007. }
  9008. return(dormt(x));
  9009. }
  9010. #endif /* NOXFER */
  9011. #ifndef NORENAME
  9012. #ifndef NOFRILLS
  9013. if (cx == XXREN || cx == XXLREN) { /* RENAME */
  9014. #ifdef LOCUS
  9015. if (!locus && cx != XXLREN) {
  9016. #ifdef NOXFER
  9017. return(-2);
  9018. #else
  9019. return(dormt(XZREN));
  9020. #endif /* NOXFER */
  9021. }
  9022. #endif /* LOCUS */
  9023. #ifdef IKSD
  9024. if (inserver && (!ENABLED(en_ren)
  9025. #ifdef CK_LOGIN
  9026. || isguest
  9027. #endif /* CK_LOGIN */
  9028. )) {
  9029. printf("?Sorry, renaming of files is disabled\n");
  9030. return(-9);
  9031. }
  9032. #endif /* IKSD */
  9033. #ifdef CK_APC
  9034. if ((apcactive == APC_LOCAL) ||
  9035. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9036. return(success = 0);
  9037. #endif /* CK_APC */
  9038. return(dorenam());
  9039. }
  9040. #endif /* NOFRILLS */
  9041. #endif /* NORENAME */
  9042. if (cx == XXEIGHT) { /* EIGHTBIT */
  9043. extern int parity, cmask, cmdmsk;
  9044. if ((x = cmcfm()) < 0)
  9045. return(x);
  9046. parity = 0;
  9047. cmask = 0xff;
  9048. cmdmsk = 0xff;
  9049. return(success = 1);
  9050. }
  9051. #ifndef NOXFER
  9052. /* SEND, CSEND, MOVE, MAIL, and RESEND use the new common code */
  9053. if (cx == XXSEN /* SEND */
  9054. #ifdef PIPESEND
  9055. || cx == XXCSEN /* CSEND */
  9056. #endif /* PIPESEND */
  9057. || cx == XXMOVE /* MOVE */
  9058. || cx == XXMAI /* MAIL */
  9059. #ifdef CK_RESEND
  9060. || cx == XXRSEN /* RESEND */
  9061. #endif /* CK_RESEND */
  9062. ) {
  9063. #ifdef IKSD
  9064. if (inserver && !ENABLED(en_get)) {
  9065. printf("?Sorry, sending files is disabled\n");
  9066. return(-9);
  9067. }
  9068. #endif /* IKSD */
  9069. return(doxsend(cx));
  9070. }
  9071. /* PSEND, ADD, and REMOVE use special parsing */
  9072. #ifdef ADDCMD
  9073. /* ADD and REMOVE */
  9074. if (cx == XXADD || cx == XXREMV) {
  9075. char * m;
  9076. m = (cx == XXADD) ? "Add to which list?" : "Remove from which list?";
  9077. x = cmkey(addtab,naddtab,m,"",xxstring);
  9078. if (x < 0)
  9079. return(x);
  9080. #ifndef NOMSEND
  9081. if (x == ADD_SND)
  9082. return(addsend(cx));
  9083. else
  9084. #endif /* NOMSEND */
  9085. return(doadd(cx,x));
  9086. }
  9087. #endif /* ADDCMD */
  9088. #ifdef CK_RESEND
  9089. if (cx == XXPSEN) { /* PSEND */
  9090. int seekto = 0; /* FIX THIS */
  9091. cmarg = cmarg2 = "";
  9092. x = cmifi("File to partially send", "", &s, &y, xxstring);
  9093. if (x < 0) {
  9094. if (x == -3) {
  9095. printf("?A file specification is required\n");
  9096. return(-9);
  9097. } else return(x);
  9098. }
  9099. nfils = -1; /* Files come from internal list. */
  9100. #ifndef NOMSEND
  9101. addlist = 0; /* Don't use SEND-LIST. */
  9102. filenext = NULL;
  9103. #endif /* NOMSEND */
  9104. ckstrncpy(line,s,LINBUFSIZ); /* Save copy of string just parsed. */
  9105. debug(F110,"PSEND line",line,0);
  9106. if (y != 0) {
  9107. printf("?Sorry, wildcards not permitted in this command\n");
  9108. return(-9);
  9109. }
  9110. if (sizeof(int) < 4) {
  9111. printf("?Sorry, this command needs 32-bit integers\n");
  9112. return(-9);
  9113. }
  9114. x = cmnum("starting position (byte number)",
  9115. "",10,&seekto,xxstring);
  9116. if (x < 0)
  9117. return(x);
  9118. zfnqfp(s,fspeclen,fspec); /* Get full path */
  9119. if ((x = cmtxt("Name to send it with","",&s,NULL)) < 0)
  9120. return(x);
  9121. ckstrncpy(tmpbuf,s,TMPBUFSIZ);
  9122. #ifdef IKSD
  9123. if (inserver && !ENABLED(en_get)) {
  9124. printf("?Sorry, sending files is disabled\n");
  9125. return(-9);
  9126. }
  9127. #endif /* IKSD */
  9128. #ifdef PIPESEND
  9129. if (sndfilter) {
  9130. printf("?Sorry, no PSEND while SEND FILTER selected\n");
  9131. return(-9);
  9132. }
  9133. #endif /* PIPESEND */
  9134. #ifdef CK_XYZ
  9135. if ((protocol == PROTO_X || protocol == PROTO_XC)) {
  9136. printf("Sorry, PSEND works only with Kermit protocol\n");
  9137. return(-9);
  9138. }
  9139. #endif /* CK_XYZ */
  9140. cmarg2 = brstrip(tmpbuf); /* Strip braces */
  9141. cmarg = line; /* File to send */
  9142. debug(F110,"PSEND filename",cmarg,0);
  9143. debug(F110,"PSEND as-name",cmarg2,0);
  9144. sendstart = seekto;
  9145. sstate = 's'; /* Set start state to SEND */
  9146. #ifndef NOMSEND
  9147. addlist = 0;
  9148. filenext = NULL;
  9149. #endif /* NOMSEND */
  9150. sendmode = SM_PSEND;
  9151. #ifdef MAC
  9152. what = W_SEND;
  9153. scrcreate();
  9154. #endif /* MAC */
  9155. if (local) { /* If in local mode, */
  9156. displa = 1; /* enable file transfer display */
  9157. }
  9158. return(0);
  9159. }
  9160. #endif /* CK_RESEND */
  9161. #endif /* NOXFER */
  9162. #ifndef NOXFER
  9163. #ifndef NOMSEND
  9164. if (cx == XXMSE || cx == XXMMOVE) {
  9165. #ifdef NEWFTP
  9166. if ((ftpget == 1) || ((ftpget == 2) && ftpisopen()))
  9167. return(doftpput(cx,0));
  9168. #endif /* NEWFTP */
  9169. #ifdef CK_XYZ
  9170. if (protocol == PROTO_X || protocol == PROTO_XC) {
  9171. printf(
  9172. "Sorry, you can only send one file at a time with XMODEM protocol\n"
  9173. );
  9174. return(-9);
  9175. }
  9176. #endif /* CK_XYZ */
  9177. return(doxsend(cx));
  9178. }
  9179. #ifdef COMMENT /* (moved to doxsend) */
  9180. if (cx == XXMSE || cx == XXMMOVE) { /* MSEND and MMOVE commands */
  9181. nfils = 0; /* Like getting a list of */
  9182. lp = line; /* files on the command line */
  9183. addlist = 0; /* Do not use SEND-LIST */
  9184. filenext = NULL; /* Ditto ! */
  9185. while (1) {
  9186. char *p;
  9187. if ((x = cmifi("Names of files to send, separated by spaces","",
  9188. &s,&y,xxstring)) < 0) {
  9189. if (x == -3) {
  9190. if (nfils <= 0) {
  9191. printf("?A file specification is required\n");
  9192. return(-9);
  9193. } else break;
  9194. }
  9195. return(x);
  9196. }
  9197. msfiles[nfils++] = lp; /* Got one, count it, point to it, */
  9198. p = lp; /* remember pointer, */
  9199. while (*lp++ = *s++) /* and copy it into buffer */
  9200. if (lp > (line + LINBUFSIZ)) { /* Avoid memory leak */
  9201. printf("?MSEND list too long\n");
  9202. line[0] = NUL;
  9203. return(-9);
  9204. }
  9205. debug(F111,"msfiles",msfiles[nfils-1],nfils-1);
  9206. if (nfils == 1) *fspec = NUL; /* Take care of \v(filespec) */
  9207. #ifdef ZFNQFP
  9208. zfnqfp(p,TMPBUFSIZ,tmpbuf);
  9209. p = tmpbuf;
  9210. #endif /* ZFNQFP */
  9211. if (((int)strlen(fspec) + (int)strlen(p) + 1) < fspeclen) {
  9212. strcat(fspec,p); /* safe */
  9213. strcat(fspec," "); /* safe */
  9214. } else printf("WARNING - \\v(filespec) buffer overflow\n");
  9215. }
  9216. cmlist = msfiles; /* Point cmlist to pointer array */
  9217. cmarg2 = ""; /* No internal expansion list (yet) */
  9218. sndsrc = nfils; /* Filenames come from cmlist */
  9219. sendmode = SM_MSEND; /* Remember this kind of SENDing */
  9220. sstate = 's'; /* Set start state for SEND */
  9221. if (cx == XXMMOVE) /* If MMOVE'ing, */
  9222. moving = 1; /* set this flag. */
  9223. #ifdef MAC
  9224. what = W_SEND;
  9225. scrcreate();
  9226. #endif /* MAC */
  9227. if (local) { /* If in local mode, */
  9228. displa = 1; /* turn on file transfer display */
  9229. ttflui(); /* and flush tty input buffer. */
  9230. }
  9231. return(0);
  9232. }
  9233. #endif /* COMMENT */
  9234. #endif /* NOMSEND */
  9235. #endif /* NOXFER */
  9236. #ifndef NOSERVER
  9237. if (cx == XXSER) { /* SERVER */
  9238. #ifdef CK_XYZ
  9239. if (protocol != PROTO_K) {
  9240. printf("Sorry, SERVER only works with Kermit protocol\n");
  9241. return(-9);
  9242. }
  9243. #endif /* CK_XYZ */
  9244. #ifdef COMMENT
  9245. /*
  9246. Parse for time limit, but since we don't use it yet,
  9247. the parsing is commented out.
  9248. */
  9249. x_ifnum = 1; /* Turn off internal complaints */
  9250. y = cmnum("optional time limit, seconds, or time of day as hh:mm:ss",
  9251. "0", 10, &x, xxstring
  9252. );
  9253. x_ifnum = 0;
  9254. if (y < 0) {
  9255. if (y == -2) { /* Invalid number or expression */
  9256. zz = tod2sec(atmbuf); /* Convert to secs since midnight */
  9257. if (zz < 0L) {
  9258. printf("?Number, expression, or time of day required\n");
  9259. return(-9);
  9260. } else {
  9261. char now[32]; /* Current time */
  9262. char *p;
  9263. long tnow;
  9264. p = now;
  9265. ztime(&p);
  9266. tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
  9267. if (zz < tnow) /* User's time before now */
  9268. zz += 86400L; /* So make it tomorrow */
  9269. zz -= tnow; /* Seconds from now. */
  9270. }
  9271. } else
  9272. return(y);
  9273. }
  9274. if (zz > -1L) {
  9275. x = zz;
  9276. if (zz != (long) x) {
  9277. printf(
  9278. "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.\n"
  9279. );
  9280. return(-9);
  9281. }
  9282. }
  9283. if (x < 0)
  9284. x = 0;
  9285. #endif /* COMMENT */
  9286. if ((x = cmcfm()) < 0) return(x);
  9287. sstate = 'x';
  9288. #ifdef MAC
  9289. what = W_RECV;
  9290. scrcreate();
  9291. #endif /* MAC */
  9292. if (local) displa = 1;
  9293. #ifdef AMIGA
  9294. reqoff(); /* No DOS requestors while server */
  9295. #endif /* AMIGA */
  9296. return(0);
  9297. }
  9298. #endif /* NOSERVER */
  9299. if (cx == XXSAVE) { /* SAVE command */
  9300. x = cmkey(savtab,nsav,"option","keymap",xxstring);
  9301. if (x == -3) {
  9302. printf("?You must specify an option to save\n");
  9303. return(-9);
  9304. }
  9305. if (x < 0) return(x);
  9306. /* have to set success separately for each item in doprm()... */
  9307. /* actually not really, could have just had doprm return 0 or 1 */
  9308. /* and set success here... */
  9309. y = dosave(x);
  9310. if (y == -3) {
  9311. printf("?More fields required\n");
  9312. return(-9);
  9313. } else return(y);
  9314. }
  9315. if (cx == XXSET) { /* SET command */
  9316. x = cmkey(prmtab,nprm,"Parameter","",xxstring);
  9317. if (x == -3) {
  9318. printf("?You must specify a parameter to set\n");
  9319. return(-9);
  9320. }
  9321. if (x < 0) return(x);
  9322. /* have to set success separately for each item in doprm()... */
  9323. /* actually not really, could have just had doprm return 0 or 1 */
  9324. /* and set success here... */
  9325. y = doprm(x,0);
  9326. if (y == -3) {
  9327. printf("?More fields required\n");
  9328. return(-9);
  9329. } else return(y);
  9330. }
  9331. #ifndef NOPUSH
  9332. if (cx == XXSHE /* SHELL (system) command */
  9333. || cx == XXEXEC /* exec() */
  9334. ) {
  9335. int rx = 0;
  9336. char * p = NULL;
  9337. int i /* ,n */ ;
  9338. #ifdef UNIXOROSK
  9339. char * args[256];
  9340. #endif /* UNIXOROSK */
  9341. #ifdef IKSD
  9342. if (inserver && (nopush || !ENABLED(en_hos))) {
  9343. printf("?Sorry, host command access is disabled\n");
  9344. return(-9);
  9345. }
  9346. #endif /* IKSD */
  9347. #ifdef CKEXEC
  9348. if (cx == XXEXEC) { /* EXEC (overlay ourselves) */
  9349. struct FDB sw, fl;
  9350. cmfdbi(&sw, /* First FDB - command switches */
  9351. _CMKEY, /* fcode */
  9352. "Command to overlay C-Kermit\n or switch", /* hlpmsg */
  9353. "", /* default */
  9354. "", /* addtl string data */
  9355. 1, /* addtl numeric data 1: tbl size */
  9356. 4, /* addtl numeric data 2: 4 = cmswi */
  9357. xxstring, /* Processing function */
  9358. redirsw, /* Keyword table */
  9359. &fl /* Pointer to next FDB */
  9360. );
  9361. cmfdbi(&fl, /* 2nd FDB - command to exec */
  9362. _CMFLD, /* fcode */
  9363. "Command to overlay C-Kermit", /* hlpmsg */
  9364. "", /* default */
  9365. "", /* addtl string data */
  9366. 0, /* addtl numeric data 1 */
  9367. 0, /* addtl numeric data 2 */
  9368. xxstring,
  9369. NULL,
  9370. NULL /* No more after this */
  9371. );
  9372. while (1) {
  9373. x = cmfdb(&sw); /* Parse something */
  9374. debug(F101,"exec cmfdb","",x);
  9375. if (x < 0)
  9376. return(x);
  9377. /* Generalize this if we add more switches */
  9378. if (cmresult.fcode == _CMKEY) {
  9379. rx = 1;
  9380. continue;
  9381. }
  9382. if (cmresult.fcode == _CMFLD)
  9383. break;
  9384. return(-2);
  9385. }
  9386. ckstrncpy(tmpbuf,cmresult.sresult,TMPBUFSIZ);
  9387. if (!tmpbuf[0]) {
  9388. printf("?Command required\n");
  9389. return(-9);
  9390. }
  9391. p = brstrip(tmpbuf);
  9392. args[0] = NULL; /* Set argv[0] to it */
  9393. makestr(&args[0],p);
  9394. for (i = 1; i < 255; i++) { /* Get arguments for command */
  9395. if ((x = cmfld("Argument","",&s,xxstring)) < 0) {
  9396. if (x == -3) {
  9397. if ((x = cmcfm()) < 0)
  9398. return(x);
  9399. break;
  9400. } else
  9401. return(x);
  9402. }
  9403. args[i] = NULL;
  9404. s = brstrip(s);
  9405. makestr(&args[i],s);
  9406. }
  9407. args[i] = NULL;
  9408. } else {
  9409. #endif /* CKEXEC */
  9410. if ((x = cmtxt("System command to execute","",&s,xxstring)) < 0)
  9411. return(x);
  9412. #ifdef CKEXEC
  9413. }
  9414. #endif /* CKEXEC */
  9415. if (nopush)
  9416. return(success = 0);
  9417. #ifdef CK_APC
  9418. if (apcactive == APC_REMOTE && !(apcstatus & APC_UNCH))
  9419. return(success = 0);
  9420. #endif /* CK_APC */
  9421. conres(); /* Make console normal */
  9422. #ifdef OS2
  9423. if (!(s && *s)) {
  9424. os2push();
  9425. return(success = 1);
  9426. } else
  9427. #endif /* OS2 */
  9428. if (cx == XXSHE) {
  9429. x = zshcmd(s);
  9430. debug(F101,"RUN zshcmd code","",x);
  9431. concb((char)escape);
  9432. return(success = x);
  9433. #ifdef CKEXEC
  9434. } else {
  9435. #ifdef DEBUG
  9436. if (deblog) {
  9437. debug(F111,"EXEC cmd",p,0);
  9438. for (i = 0; i < 256 && args[i]; i++)
  9439. debug(F111,"EXEC arg",args[i],i);
  9440. }
  9441. #endif /* DEBUG */
  9442. if (p) {
  9443. z_exec(p,args,rx); /* Overlay ourself */
  9444. debug(F100,"EXEC fails","",0);
  9445. concb((char)escape); /* In case it returns */
  9446. }
  9447. return(success = 0);
  9448. #endif /* CKEXEC */
  9449. }
  9450. }
  9451. #ifdef CK_REDIR
  9452. if (cx == XXFUN) { /* REDIRECT */
  9453. #ifdef CK_APC
  9454. if ((apcactive == APC_LOCAL) ||
  9455. ((apcactive == APC_REMOTE) && (!(apcstatus & APC_UNCH))))
  9456. return(success = 0);
  9457. #endif /* CK_APC */
  9458. ckmakmsg(tmpbuf,
  9459. TMPBUFSIZ,
  9460. "Local command to run,\n",
  9461. "with its standard input/output redirected to ",
  9462. local ? ttname : "the communications connection",
  9463. "\n"
  9464. );
  9465. if ((x = cmtxt(tmpbuf,"",&s,xxstring)) < 0)
  9466. return(x);
  9467. if (nopush) {
  9468. printf("?REDIRECT disabled\n");
  9469. return(success=0);
  9470. }