ckuusy.c 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760
  1. #include "ckcsym.h"
  2. #define XFATAL fatal
  3. /* C K U U S Y -- "User Interface" for C-Kermit Kermit, part Y */
  4. /* Command-Line Argument Parser */
  5. /*
  6. Authors:
  7. Frank da Cruz <fdc@columbia.edu>,
  8. The Kermit Project, New York City
  9. Jeffrey E Altman <jaltman@secure-endpoints.com>
  10. Secure Endpoints Inc., New York City
  11. Copyright (C) 1985, 2014,
  12. Trustees of Columbia University in the City of New York.
  13. All rights reserved. See the C-Kermit COPYING.TXT file or the
  14. copyright text in the ckcmai.c module for disclaimer and permissions.
  15. Most recent update:
  16. Sun Feb 23 09:39:28 2014
  17. */
  18. #include "ckcdeb.h"
  19. char * bannerfile = NULL;
  20. char * helpfile = NULL;
  21. extern int xferlog, filepeek, nolinks;
  22. extern char * xferfile;
  23. extern int debtim;
  24. #include "ckcasc.h"
  25. #include "ckcker.h"
  26. #include "ckucmd.h"
  27. #include "ckcnet.h"
  28. #include "ckuusr.h"
  29. #include "ckcxla.h"
  30. #ifdef CK_SSL
  31. #include "ck_ssl.h"
  32. #endif /* CK_SSL */
  33. #include <signal.h>
  34. #ifdef OS2
  35. #include <io.h>
  36. #ifdef KUI
  37. #include "ikui.h"
  38. extern struct _kui_init kui_init;
  39. #endif /* KUI */
  40. #endif /* OS2 */
  41. extern int inserver, fncnv, f_save, xfermode;
  42. #ifdef PATTERNS
  43. extern int patterns;
  44. #endif /* PATTERNS */
  45. #ifndef NOICP
  46. extern int cmdint;
  47. #endif /* NOICP */
  48. extern int xsuspend;
  49. #ifdef NETCONN
  50. #ifdef ANYX25
  51. extern int revcall, closgr, cudata;
  52. extern char udata[];
  53. extern int x25fd;
  54. #endif /* ANYX25 */
  55. #ifndef VMS
  56. #ifndef OS2
  57. #ifndef OSK
  58. extern
  59. #endif /* OSK */
  60. #endif /* OS2 */
  61. #endif /* VMS */
  62. int telnetfd;
  63. extern struct keytab netcmd[];
  64. extern int tn_exit;
  65. #ifndef NOICP
  66. #ifndef NODIAL
  67. extern int nnets, nnetdir; /* Network services directory */
  68. extern char *netdir[];
  69. extern char *nh_p[]; /* Network directory entry pointers */
  70. extern char *nh_p2[]; /* Network directory entry nettype */
  71. extern char *nh_px[4][MAXDNUMS + 1];
  72. #endif /* NODIAL */
  73. extern int nhcount;
  74. extern char * n_name; /* Network name pointer */
  75. #endif /* NOICP */
  76. #endif /* NETCONN */
  77. #ifndef NOSPL
  78. extern int nmac;
  79. extern struct mtab *mactab;
  80. #endif /* NOSPL */
  81. extern char uidbuf[];
  82. #ifdef CK_LOGIN
  83. extern int logintimo;
  84. #endif /* CK_LOGIN */
  85. extern char * myname, * dftty;
  86. extern int howcalled;
  87. extern char *ckxsys, *ckzsys, **xargv, *xarg0, **cmlist, *clcmds;
  88. extern int action, cflg, xargc, cnflg, local, quiet, escape, network, mdmtyp,
  89. bgset, backgrd, xargs, binary, parity, turn, turnch, duplex, flow, clfils,
  90. noinit, stayflg, nettype, cfilef, noherald, cmask, cmdmsk, exitonclose,
  91. haveline, justone, cxtype, xfinish, ttnproto;
  92. extern long speed;
  93. extern char ttname[];
  94. extern char * pipedata, cmdfil[];
  95. #ifndef NOXFER
  96. extern char *cmarg, *cmarg2;
  97. extern int nfils, stdouf, stdinf, displa, maxrps, rpsiz, ckwarn, urpsiz,
  98. wslotr, swcapr, ckdelay, recursive, reliable, xreliable, fnspath, fncact,
  99. clearrq, setreliable;
  100. #ifdef PIPESEND
  101. extern int usepipes, pipesend;
  102. #endif /* PIPESEND */
  103. extern int protocol;
  104. #endif /* NOXFER */
  105. #ifndef NOPUSH
  106. extern int nopush;
  107. #endif /* NOPUSH */
  108. #ifdef OS2
  109. extern struct keytab os2devtab[];
  110. extern int nos2dev;
  111. extern int ttslip;
  112. extern int tt_scroll, tt_escape;
  113. #ifdef OS2PM
  114. extern int os2pm;
  115. #endif /* OS2PM */
  116. #endif /* OS2 */
  117. #ifdef CK_NETBIOS
  118. extern unsigned char NetBiosAdapter;
  119. #endif /* CK_NETBIOS */
  120. #ifdef XFATAL
  121. #undef XFATAL
  122. #endif /* XFATAL */
  123. #ifdef TNCODE
  124. _PROTOTYP(static int dotnarg, (char x) );
  125. #endif /* TNCODE */
  126. #ifdef RLOGCODE
  127. _PROTOTYP(static int dorlgarg, (char x) );
  128. #endif /* RLOGCODE */
  129. #ifdef SSHBUILTIN
  130. _PROTOTYP(static int dossharg, (char x) );
  131. #endif /* SSHBUILTIN */
  132. int haveftpuid = 0; /* Have FTP user ID */
  133. static int have_cx = 0; /* Have connection */
  134. static char * failmsg = NULL; /* Failure message */
  135. #ifdef NEWFTP
  136. extern char * ftp_host;
  137. #endif /* NEWFTP */
  138. extern int what;
  139. #ifndef NOICP
  140. #ifndef NODIAL
  141. extern int nmdm, telephony;
  142. extern struct keytab mdmtab[];
  143. extern int usermdm, dialudt;
  144. #endif /* NODIAL */
  145. _PROTOTYP(static int pmsg, (char *) );
  146. _PROTOTYP(static int fmsg, (char *) );
  147. static int pmsg(s) char *s; { printf("%s\n", s); return(0); }
  148. static int fmsg(s) char *s; { fatal(s); return(0); }
  149. #define XFATAL(s) return(what==W_COMMAND?pmsg(s):fmsg(s))
  150. #else
  151. #define XFATAL fatal
  152. #endif /* NOICP */
  153. #ifndef NOHTTP
  154. #define HTTP_GET 1
  155. #define HTTP_PUT 2
  156. #define HTTP_HED 3
  157. #endif /* NOHTTP */
  158. #ifdef CK_URL
  159. /* URLs we recognize */
  160. #define URL_FTP 1
  161. #define URL_HTTP 2
  162. #define URL_HTTPS 3
  163. #define URL_IKSD 4
  164. #define URL_TELNET 5
  165. #define URL_LOGIN 6
  166. struct keytab urltab[] = {
  167. #ifdef NEWFTP
  168. "ftp", URL_FTP, 0,
  169. #endif /* NEWFTP */
  170. #ifndef NOHTTP
  171. "http", URL_HTTP, 0,
  172. "https", URL_HTTPS, 0,
  173. #endif /* NOHTTP */
  174. "iksd", URL_IKSD, 0,
  175. "kermit", URL_IKSD, 0,
  176. "telnet", URL_TELNET, 0,
  177. "", 0, 0
  178. };
  179. int nurltab = sizeof(urltab)/sizeof(struct keytab) - 1;
  180. #ifndef URLBUFLEN
  181. #define URLBUFLEN 1024
  182. #endif /* URLBUFLEN */
  183. static char urlbuf[URLBUFLEN];
  184. struct urldata g_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  185. /* u r l p a r s e -- Parse a possible URL */
  186. /*
  187. Returns 0 if the candidate does not seem to be a URL.
  188. Returns 1 if it might be a URL, with the above pointers set to its pieces:
  189. service : [ // ] [ user [ : password ] @ ] host [ : service ] [ / path ] -
  190. [ ? name [ = value ]]
  191. Example: ftp://ds.internic.net:21/rfc/rfc1234.txt
  192. url.svc = [ftp]
  193. url.usr = [(NULL)]
  194. url.psw = [(NULL)]
  195. url.hos = [ds.internic.net]
  196. url.por = [21]
  197. url.pth = [rfc/rfc1234.txt]
  198. It might be a URL if it contains a possible service name followed by a
  199. a colon (:). Thus "telnet:xyzcorp.com" is a minimal URL, whereas a
  200. full-blown example would be:
  201. ftp://olga:secret@ftp.xyzcorp.com/public/oofa.txt
  202. The caller must verify the results, i.e. that the service string is a real
  203. TCP service, etc. This routine just parses the fields.
  204. struct urldata defined in ckcker.h
  205. */
  206. int
  207. urlparse(s,url) char *s; struct urldata * url; {
  208. char * p = NULL, * urlbuf = NULL;
  209. int x;
  210. if (!s || !url)
  211. return(0);
  212. if (!*s)
  213. return(0);
  214. makestr(&urlbuf,s);
  215. if (url->sav) { /* In case we were called before... */
  216. free(url->sav);
  217. url->sav = NULL;
  218. }
  219. if (url->svc) {
  220. free(url->svc);
  221. url->svc = NULL;
  222. }
  223. if (url->hos) {
  224. free(url->hos);
  225. url->hos = NULL;
  226. }
  227. if (url->por) {
  228. free(url->por);
  229. url->por = NULL;
  230. }
  231. if (url->usr) {
  232. free(url->usr);
  233. url->usr = NULL;
  234. }
  235. if (url->psw) {
  236. free(url->psw);
  237. url->psw = NULL;
  238. }
  239. if (url->pth) {
  240. free(url->pth);
  241. url->pth = NULL;
  242. }
  243. if (url->nopts) {
  244. int i;
  245. for (i = 0; i < url->nopts && i < MAX_URL_OPTS; i++ ) {
  246. if (url->opt[i].nam) {
  247. free(url->opt[i].nam);
  248. url->opt[i].nam = NULL;
  249. }
  250. if (url->opt[i].val) {
  251. free(url->opt[i].val);
  252. url->opt[i].val = NULL;
  253. }
  254. }
  255. url->nopts = 0;
  256. }
  257. p = urlbuf; /* Was a service requested? */
  258. while (*p && *p != ':') /* Look for colon */
  259. p++;
  260. if (*p == ':') { /* Have a colon */
  261. *p++ = NUL; /* Get service name or number */
  262. if (*p == ':') /* a second colon */
  263. *p++ = NUL; /* get rid of that one too */
  264. while (*p == '/') *p++ = NUL; /* and slashes */
  265. #ifdef COMMENT
  266. /* Trailing slash is part of path - leave it - jaltman */
  267. x = strlen(p); /* Length of remainder */
  268. if (p[x-1] == '/') /* If there is a trailing slash */
  269. p[x-1] = NUL; /* remove it. */
  270. #endif /* COMMENT */
  271. if (urlbuf[0]) { /* Anything left? */
  272. char *q = p, *r = p, *w = p;
  273. makestr(&url->svc,urlbuf);
  274. while (*p != NUL && *p != '@') /* look for @ */
  275. p++;
  276. if (*p == '@') { /* Signifies user ID, maybe password */
  277. *p++ = NUL;
  278. url->hos = p;
  279. while (*w != NUL && *w != ':')
  280. w++;
  281. if (*w == ':')
  282. *w++ = NUL;
  283. url->usr = r; /* Username */
  284. if (*w)
  285. url->psw = w; /* Password */
  286. q = p;
  287. } else { /* No username or password */
  288. p = q;
  289. url->hos = p;
  290. }
  291. #ifdef COMMENT
  292. debug(F111,"urlparse url->usr",url->usr,url->usr);
  293. debug(F111,"urlparse url->psw",url->usr,url->psw);
  294. debug(F111,"urlparse url->hos",url->usr,url->hos);
  295. #endif /* COMMENT */
  296. while (*p != NUL && *p != ':' && *p != '/') /* Port? */
  297. p++;
  298. if (*p == ':') { /* TCP port */
  299. *p++ = NUL;
  300. r = p;
  301. url->por = r;
  302. while (*p != NUL && *p != '/')
  303. p++;
  304. /* '/' is part of path, leave it until we can copy */
  305. if (*p == '/') {
  306. makestr(&url->pth,p); /* Path */
  307. *p = NUL;
  308. }
  309. } else { /* No port */
  310. /* '/' is part of path, leave it */
  311. if (*p == '/') {
  312. makestr(&url->pth,p); /* Path */
  313. *p = NUL;
  314. }
  315. }
  316. }
  317. /* Copy non-NULL result strings */
  318. if (url->svc) if (*url->svc) {
  319. p = url->svc;
  320. url->svc = NULL;
  321. makestr(&url->svc,p);
  322. }
  323. if (url->hos) if (*url->hos) {
  324. p = url->hos;
  325. url->hos = NULL;
  326. makestr(&url->hos,p);
  327. }
  328. if (url->por) if (*url->por) {
  329. p = url->por;
  330. url->por = NULL;
  331. makestr(&url->por,p);
  332. }
  333. /*
  334. WARNING (Wed Oct 9 16:09:03 2002): We now allow the username and
  335. password to be empty strings. These are treated differently from null
  336. pointers: an empty string means the URL included username and/or password
  337. fields that were empty, e.g. ftp://:@ftp.xyzcorp.com/somepath/somefile,
  338. which causes the client to prompt for the username and/or password.
  339. */
  340. if (url->usr) /* if (*url->usr) */ {
  341. p = url->usr;
  342. url->usr = NULL;
  343. makestr(&url->usr,p);
  344. }
  345. if (url->psw) /* if (*url->psw) */ {
  346. p = url->psw;
  347. url->psw = NULL;
  348. makestr(&url->psw,p);
  349. }
  350. /* Save a copy of the full url if one was found. */
  351. if (url->svc)
  352. makestr(&url->sav,s);
  353. free(urlbuf);
  354. return(url->svc ? 1 : 0);
  355. }
  356. return(0);
  357. }
  358. #endif /* CK_URL */
  359. #ifndef NOCMDL
  360. char *hlp1[] = {
  361. #ifndef NOICP
  362. " [filename] [-x arg [-x arg]...[-yyy]..] [ = text ] ]\n",
  363. #else
  364. "[-x arg [-x arg]...[-yyy]..]\n",
  365. #endif /* NOICP */
  366. "\n",
  367. " -x is an option requiring an argument, -y an option with no argument.\n",
  368. " If the first command-line argument is the name of a file, interactive-\n",
  369. " mode commands are executed from the file. The '=' argument tells Kermit\n",
  370. " not to parse the remainder of the command line, but to make the words\n",
  371. " following '=' available as \\%1, \\%2, ... \\%9. The command file \
  372. (if any)\n",
  373. " is executed before the command-line options.\n",
  374. "\n",
  375. #ifndef NOICP
  376. "If no action command is included, or -S is, then after the command line is\n",
  377. "executed, Kermit issues its prompt and waits for you to type commands.\n",
  378. #else
  379. "Operation by command-line options only.\n",
  380. #endif /* NOICP */
  381. ""
  382. };
  383. static
  384. char *hlp2[] = {
  385. " [option-list] host[:port] [port]\n",
  386. " The option-list consists of zero, one, or more of:\n",
  387. " -8 Negotiate Telnet Binary in both directions\n",
  388. " -a Require use of Telnet authentication\n",
  389. " -d Turn on debug mode\n",
  390. " -E No escape character\n",
  391. " -K Refuse use of authentication; do not send username\n",
  392. " -l user Set username and request Telnet authentication\n",
  393. " -L Negotiate Telnet Binary Output only\n",
  394. " -x Require Encryption\n",
  395. " -D Disable forward-X\n",
  396. " -T cert=file Use certificate in file\n",
  397. " -T key=file Use private key in file\n",
  398. " -T crlfile=file Use CRL in file\n",
  399. " -T crldir=dir Use CRLs in directory\n",
  400. " -T cipher=string Use only ciphers in string\n",
  401. " -f Forward credentials to host\n",
  402. " -k realm Set default Kerberos realm\n",
  403. ""
  404. };
  405. static
  406. char *hlp3[] = { /* rlogin */
  407. " [option-list] host[:port] [port]\n",
  408. " The option-list consists of zero, one, or more of:\n",
  409. " -d Turn on debug mode\n",
  410. " -l user Set username\n",
  411. ""
  412. };
  413. static
  414. char *hlp4[] = { /* ssh */
  415. " [option-list] host[:port] [port]\n",
  416. " The option-list consists of zero, one, or more of:\n",
  417. #ifdef OS2
  418. " -# flags Kermit 95 Startup Flags\n",
  419. " 1 turn off Win95 special fixes\n",
  420. " 2 do not load optional network dlls\n",
  421. " 4 do not load optional tapi dlls\n",
  422. " 8 do not load optional kerberos dlls\n",
  423. " 16 do not load optional zmodem dlls\n",
  424. " 32 use stdin for input instead of the console\n",
  425. " 64 use stdout for output instead of the console\n",
  426. " 128 do not terminate process in response to Session Logoff\n",
  427. #endif /* OS2 */
  428. " -d Turn on debug mode\n",
  429. " -Y Disable init file processing\n",
  430. " -l user Set username\n",
  431. ""
  432. };
  433. /* Command-line option help lines. Update this when adding new options! */
  434. char * opthlp[128]; /* Option help */
  435. char * arghlp[128]; /* Argument for option */
  436. int optact[128]; /* Action-option flag */
  437. VOID
  438. fatal2(msg1,msg2) char *msg1, *msg2; {
  439. char buf[256];
  440. if (!msg1) msg1 = "";
  441. if (!msg2) msg2 = "";
  442. ckmakmsg(buf,256,"\"",msg1,"\" - ",msg2);
  443. #ifndef NOICP
  444. if (what == W_COMMAND)
  445. printf("%s\n",buf);
  446. else
  447. #endif /* NOICP */
  448. fatal((char *)buf);
  449. }
  450. static SIGTYP
  451. #ifdef CK_ANSI
  452. cl_int(int dummy)
  453. #else /* CK_ANSI */
  454. cl_int(dummy) int dummy;
  455. #endif /* CK_ANSI */
  456. { /* Command-line interrupt handler */
  457. doexit(BAD_EXIT,1);
  458. SIGRETURN;
  459. }
  460. #ifdef NEWFTP
  461. extern int ftp_action, ftp_cmdlin;
  462. static int
  463. xx_ftp(host, port) char * host, * port; {
  464. #ifdef CK_URL
  465. extern int haveurl;
  466. #endif /* CK_URL */
  467. extern char * ftp_logname;
  468. int use_tls = 0;
  469. char * p;
  470. if (port) if (!*port) port = NULL;
  471. if (!host)
  472. return(0);
  473. if (!*host)
  474. return(0);
  475. debug(F111,"ftp xx_ftp host",ftp_host,haveftpuid);
  476. debug(F111,"ftp xx_ftp uidbuf 1",uidbuf,haveftpuid);
  477. ftp_cmdlin = 1; /* 1 = FTP started from command line */
  478. if (nfils > 0)
  479. ftp_cmdlin++; /* 2 = same plus file transfer */
  480. #ifndef NOURL
  481. /* debug(F111,"ftp xx_ftp g_url.usr",g_url.usr,g_url.usr); */
  482. if (haveurl && g_url.usr) { /* Wed Oct 9 15:15:22 2002 */
  483. if (!*(g_url.usr)) { /* Force username prompt if */
  484. haveftpuid = 0; /* "ftp://:@host" given. */
  485. uidbuf[0] = NUL;
  486. makestr(&ftp_logname,NULL);
  487. }
  488. debug(F111,"ftp xx_ftp uidbuf 2",uidbuf,haveftpuid);
  489. }
  490. #endif /* NOURL */
  491. debug(F111,"ftp xx_ftp uidbuf 3",uidbuf,haveftpuid);
  492. if (haveftpuid) {
  493. makestr(&ftp_logname,uidbuf);
  494. debug(F111,"ftp_logname",ftp_logname,haveftpuid);
  495. }
  496. if (!port) {
  497. if ((p = ckstrchr(ftp_host,':')))
  498. *p++ = NUL;
  499. port = p;
  500. }
  501. if (!port) {
  502. #ifdef CK_URL
  503. if (haveurl) {
  504. if (g_url.por)
  505. port = g_url.por;
  506. else if (g_url.svc)
  507. port = g_url.svc;
  508. else
  509. port = "ftp";
  510. } else
  511. #endif /* CK_URL */
  512. port = "ftp";
  513. }
  514. #ifdef CK_SSL
  515. if (haveurl && g_url.svc)
  516. use_tls = !ckstrcmp("ftps",g_url.svc,-1,0);
  517. #endif /* CK_SSL */
  518. if (ftpopen(ftp_host,port,use_tls) < 1)
  519. return(-1);
  520. debug(F111,"ftp xx_ftp action",ckctoa((char)ftp_action),nfils);
  521. if (nfils > 0) {
  522. switch (ftp_action) {
  523. case 'g':
  524. return(cmdlinget(stayflg));
  525. case 'p':
  526. case 's':
  527. return(cmdlinput(stayflg));
  528. }
  529. }
  530. return(1);
  531. }
  532. #endif /* NEWFTP */
  533. #ifndef NOHTTP
  534. static
  535. char * http_hlp[] = {
  536. " -h This message.\n",
  537. " -d Debug to debug.log.\n",
  538. " -S Stay (issue command prompt when done).\n",
  539. " -Y Do not execute Kermit initialization file.\n",
  540. " -q Quiet (suppress most messages).\n",
  541. " -u name Username.\n",
  542. " -P password Password.\n",
  543. " -g pathname Get remote pathname.\n",
  544. " -p pathname Put remote pathname.\n",
  545. " -H pathname Head remote pathname.\n",
  546. " -l pathname Local path for -g, -p, and -H.\n",
  547. #ifdef CK_SSL
  548. " -z opt[=value] Security options...\n",
  549. " cert=file Client certificate file\n",
  550. " certsok Accept all certificates\n",
  551. " key=file Client private key file\n",
  552. " secure Use SSL\n",
  553. " verify=n 0 = none, 1 = peer , 2 = certificate required\n",
  554. #endif /* CK_SSL */
  555. ""
  556. };
  557. #define HT_CERTFI 0
  558. #define HT_OKCERT 1
  559. #define HT_KEY 2
  560. #define HT_SECURE 3
  561. #define HT_VERIFY 4
  562. static struct keytab httpztab[] = {
  563. { "cert", HT_CERTFI, CM_ARG },
  564. { "certsok", HT_OKCERT, 0 },
  565. { "key", HT_KEY, CM_ARG },
  566. { "secure", HT_SECURE, 0 },
  567. { "verify", HT_VERIFY, CM_ARG },
  568. { "", 0, 0 }
  569. };
  570. static int nhttpztab = sizeof(httpztab) / sizeof(struct keytab) - 1;
  571. #endif /* NOHTTP */
  572. /* U S A G E */
  573. VOID
  574. usage() {
  575. #ifdef MINIX
  576. conol("Usage: ");
  577. conol(xarg0);
  578. conol(" [-x arg [-x arg]...[-yyy]..] ]\n");
  579. #else
  580. conol("Usage: ");
  581. conol(xarg0);
  582. if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
  583. howcalled == I_AM_SSHSUB)
  584. conola(hlp1);
  585. else if (howcalled == I_AM_TELNET)
  586. conola(hlp2);
  587. else if (howcalled == I_AM_RLOGIN)
  588. conola(hlp3);
  589. else if (howcalled == I_AM_SSH)
  590. conola(hlp4);
  591. if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
  592. howcalled == I_AM_SSHSUB) {
  593. int c;
  594. conoll("");
  595. conoll("Complete listing of command-line options:");
  596. conoll("");
  597. for (c = 31; c < 128; c++) {
  598. if (!opthlp[c])
  599. continue;
  600. if (arghlp[c]) {
  601. printf(" -%c <arg>%s\n",
  602. (char)c,
  603. (optact[c] ? " (action option)" : "")
  604. );
  605. printf(" %s\n",opthlp[c]);
  606. printf(" Argument: %s\n\n",arghlp[c]);
  607. } else { /* Option without arg */
  608. printf(" -%c %s%s\n",
  609. (char)c, opthlp[c],
  610. (optact[c]?" (action option)":"")
  611. );
  612. printf(" Argument: (none)\n\n");
  613. }
  614. }
  615. #ifdef OS2ORUNIX
  616. printf("To prevent this message from scrolling, use '%s -h | more'.\n",
  617. xarg0);
  618. #endif /* OS2ORUNIX */
  619. printf("For a list of extended options use '%s --help'.\n",
  620. xarg0);
  621. }
  622. #endif /* MINIX */
  623. }
  624. /* C M D L I N -- Get arguments from command line */
  625. int
  626. cmdlin() {
  627. char x; /* Local general-purpose char */
  628. extern int haveurl;
  629. #ifdef NEWFTP
  630. char * port = NULL;
  631. #endif /* NEWFTP */
  632. #ifndef NOXFER
  633. cmarg = ""; /* Initialize globals */
  634. cmarg2 = "";
  635. #endif /* NOXFER */
  636. action = 0;
  637. cflg = 0;
  638. signal(SIGINT,cl_int);
  639. /* Here we handle different "Command Line Personalities" */
  640. #ifdef TCPSOCKET
  641. #ifndef NOHTTP
  642. if (howcalled == I_AM_HTTP) { /* If I was called as HTTP... */
  643. char rdns[128];
  644. #ifdef OS2
  645. char * agent = "Kermit 95";
  646. #else
  647. char * agent = "C-Kermit";
  648. #endif /* OS2 */
  649. debug(F100,"http personality","",0);
  650. #ifdef CK_URL
  651. if (haveurl) {
  652. int type;
  653. char * lfile;
  654. type = lookup(urltab,g_url.svc,nurltab,NULL);
  655. if (!(type == URL_HTTP || type == URL_HTTPS)) {
  656. printf("?Internal Error: HTTP command line processing\n");
  657. debug(F100,"Error: HTTP command line processing","",0);
  658. doexit(BAD_EXIT,1);
  659. }
  660. rdns[0] = '\0';
  661. lfile = "";
  662. x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc,
  663. type == URL_HTTPS, rdns,128,NULL) == 0);
  664. if (x) {
  665. #ifdef KUI
  666. char asname[CKMAXPATH+1];
  667. #endif /* KUI */
  668. if (!quiet) {
  669. if (rdns[0])
  670. printf("Connected to %s [%s]\r\n",g_url.hos,rdns);
  671. else
  672. printf("Connected to %s\r\n",g_url.hos);
  673. }
  674. if (g_url.pth)
  675. zstrip(g_url.pth,&lfile);
  676. else
  677. g_url.pth = "/";
  678. if (!*lfile)
  679. lfile = "index.html";
  680. #ifdef KUI
  681. if (uq_file(NULL, /* K95 GUI: Put up file box. */
  682. NULL, /* (not tested...) */
  683. 4,
  684. NULL,
  685. lfile,
  686. asname,
  687. CKMAXPATH+1
  688. ) > 0)
  689. lfile = asname;
  690. #endif /* KUI */
  691. x = http_get(agent,
  692. NULL, /* hdrlist */
  693. g_url.usr,
  694. g_url.psw,
  695. 0,
  696. lfile,
  697. g_url.pth,
  698. 0 /* stdio */
  699. );
  700. x = (http_close() == 0);
  701. } else {
  702. if (!quiet)
  703. printf("?HTTP Connection failed.\r\n");
  704. }
  705. doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
  706. } else
  707. #endif /* CK_URL */
  708. {
  709. int http_action = 0;
  710. char * host = NULL, * svc = NULL, * lpath = NULL;
  711. char * user = NULL, * pswd = NULL, * path = NULL;
  712. char * xp;
  713. while (--xargc > 0) { /* Go through command line words */
  714. xargv++;
  715. debug(F111,"cmdlin http xargv",*xargv,xargc);
  716. xp = *xargv+1;
  717. if (**xargv == '-') { /* Got an option */
  718. int xx;
  719. x = *(*xargv+1); /* Get the option letter */
  720. switch (x) {
  721. case 'd': /* Debug */
  722. #ifdef DEBUG
  723. if (deblog) {
  724. debtim = 1;
  725. } else {
  726. deblog = debopn("debug.log",0);
  727. }
  728. #endif /* DEBUG */
  729. break;
  730. case 'S': /* Stay */
  731. case 'Y': /* No initialization file */
  732. break; /* (already done in prescan) */
  733. case 'q': /* Quiet */
  734. quiet = 1;
  735. break;
  736. case 'u': /* Options that require arguments */
  737. case 'P':
  738. case 'g':
  739. case 'p':
  740. case 'H':
  741. case 'l':
  742. if (*(xp+1)) {
  743. XFATAL("Invalid argument bundling");
  744. }
  745. xargv++, xargc--;
  746. if ((xargc < 1) || (**xargv == '-')) {
  747. XFATAL("Missing argument");
  748. }
  749. switch (x) {
  750. case 'u':
  751. user = *xargv;
  752. break;
  753. case 'P':
  754. pswd = *xargv;
  755. break;
  756. case 'l':
  757. if (http_action != HTTP_PUT)
  758. lpath = *xargv;
  759. break;
  760. case 'g':
  761. http_action = HTTP_GET;
  762. path = *xargv;
  763. debug(F111,"cmdlin http GET",path,http_action);
  764. break;
  765. case 'p':
  766. http_action = HTTP_PUT;
  767. path = *xargv;
  768. break;
  769. case 'H':
  770. http_action = HTTP_HED;
  771. path = *xargv;
  772. }
  773. break;
  774. #ifdef CK_SSL
  775. case 'z': {
  776. /* *xargv contains a value of the form tag=value */
  777. /* we need to lookup the tag and save the value */
  778. int x,y,z;
  779. char * p, * q;
  780. makestr(&p,*xargv);
  781. y = ckindex("=",p,0,0,1);
  782. if (y > 0)
  783. p[y-1] = '\0';
  784. x = lookup(httpztab,p,nhttpztab,&z);
  785. if (x < 0) {
  786. printf("?Invalid security option: \"%s\"\n",p);
  787. } else {
  788. printf("Security option: \"%s",p);
  789. if (httpztab[z].flgs & CM_ARG) {
  790. q = &p[y];
  791. if (!*q)
  792. fatal("?Missing required value");
  793. }
  794. /* -z options w/args */
  795. switch (httpztab[z].kwval) {
  796. case HT_CERTFI:
  797. makestr(&ssl_rsa_cert_file,q);
  798. break;
  799. case HT_OKCERT:
  800. ssl_certsok_flag = 1;
  801. break;
  802. case HT_KEY:
  803. makestr(&ssl_rsa_key_file,q);
  804. break;
  805. case HT_SECURE:
  806. svc="https";
  807. break;
  808. case HT_VERIFY:
  809. if (!rdigits(q))
  810. printf("?Bad number: %s\n",q);
  811. ssl_verify_flag = atoi(q);
  812. break;
  813. }
  814. }
  815. free(p);
  816. break;
  817. }
  818. #endif /* CK_SSL */
  819. case 'h': /* Help */
  820. default:
  821. printf("Usage: %s host [ options... ]\n",xarg0);
  822. conola(http_hlp);
  823. doexit(GOOD_EXIT,-1);
  824. }
  825. } else { /* No dash - must be hostname */
  826. host = *xargv;
  827. if (xargc > 1) {
  828. svc = *(xargv+1);
  829. if (svc) if (*svc == '-' || !*svc)
  830. svc = NULL;
  831. if (svc) {
  832. xargv++;
  833. xargc--;
  834. }
  835. }
  836. }
  837. }
  838. if (!svc) svc = "";
  839. if (!*svc) svc = "http";
  840. if (!host) XFATAL("No http host given");
  841. /* Check action args before opening the connection */
  842. if (http_action) {
  843. if (http_action == HTTP_PUT) {
  844. if (!lpath)
  845. XFATAL("No local path for http PUT");
  846. }
  847. if (!path)
  848. XFATAL("No remote path for http action");
  849. }
  850. /* Now it's OK to open the connection */
  851. rdns[0] = NUL;
  852. x = (http_open(host,
  853. svc,!ckstrcmp("https",svc,-1,0),rdns,128,NULL
  854. ) == 0);
  855. if (!x) {
  856. if (!quiet)
  857. printf("?HTTP Connection failed.\r\n");
  858. doexit(BAD_EXIT,-1);
  859. }
  860. if (!quiet) {
  861. if (rdns[0])
  862. printf("Connected to %s [%s]\r\n",host,rdns);
  863. else
  864. printf("Connected to %s\r\n",host);
  865. }
  866. if (http_action) {
  867. int pcpy = 0;
  868. if (http_action != HTTP_PUT) { /* Supply default */
  869. if (!lpath) { /* local path... */
  870. zstrip(path,&lpath);
  871. if (!lpath)
  872. lpath = "";
  873. if (!*lpath)
  874. lpath = "index.html";
  875. }
  876. }
  877. if (*path != '/') {
  878. char * p = (char *) malloc(strlen(path)+2);
  879. if (!p) fatal("?Memory allocation error\n");
  880. *p = '/';
  881. strcpy(&p[1],path); /* safe */
  882. path = p;
  883. pcpy = 1;
  884. }
  885. switch (http_action) {
  886. case HTTP_GET:
  887. x = http_get(agent,NULL,user,pswd,0,lpath,path,0);
  888. break;
  889. case HTTP_PUT:
  890. x = http_put(agent,NULL,"text/HTML",
  891. user,pswd,0,lpath,path,NULL,0);
  892. break;
  893. case HTTP_HED:
  894. x = http_head(agent,NULL,user,pswd,0,lpath,path,0);
  895. break;
  896. }
  897. debug(F101,"cmdline http result","",x);
  898. x = (http_close() == 0);
  899. if (pcpy) free(path);
  900. doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
  901. }
  902. return(0);
  903. }
  904. } else
  905. #endif /* NOHTTP */
  906. #ifdef NEWFTP
  907. if (howcalled == I_AM_FTP) { /* If I was called as FTP... */
  908. debug(F100,"ftp personality","",0);
  909. #ifdef CK_URL
  910. if (haveurl)
  911. doftparg('U');
  912. else
  913. #endif /* CK_URL */
  914. {
  915. while (--xargc > 0) { /* Go through command line words */
  916. xargv++;
  917. debug(F111,"cmdlin ftp xargv",*xargv,xargc);
  918. if (**xargv == '-') { /* Got an option */
  919. int xx;
  920. x = *(*xargv+1); /* Get the option letter */
  921. xx = doftparg(x);
  922. if (xx < 0) {
  923. if (what == W_COMMAND)
  924. return(0);
  925. else
  926. doexit(BAD_EXIT,1);
  927. }
  928. } else { /* No dash - must be hostname */
  929. makestr(&ftp_host,*xargv);
  930. if (xargc > 1) {
  931. port = *(xargv+1);
  932. if (port) if (*port == '-' || !*port)
  933. port = NULL;
  934. if (port) {
  935. xargv++;
  936. xargc--;
  937. }
  938. }
  939. debug(F110,"cmdlin ftp host",ftp_host,0);
  940. debug(F110,"cmdlin ftp port",port,0);
  941. }
  942. } /* while */
  943. } /* if (haveurl) */
  944. if (ftp_host) {
  945. int xx;
  946. #ifdef NODIAL
  947. xx = xx_ftp(ftp_host,port);
  948. if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
  949. #else
  950. #ifdef NOICP
  951. xx = xx_ftp(ftp_host,port);
  952. if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
  953. #else
  954. if (*ftp_host == '=') { /* Skip directory lookup */
  955. xx = xx_ftp(&ftp_host[1],port);
  956. if (xx < 0 && (haveurl || ftp_cmdlin > 1))
  957. doexit(BAD_EXIT,-1);
  958. } else { /* Want lookup */
  959. int i;
  960. nhcount = 0; /* Check network directory */
  961. debug(F101,"cmdlin nnetdir","",nnetdir);
  962. if (nnetdir > 0) /* If there is a directory... */
  963. lunet(ftp_host); /* Look up the name */
  964. else /* If no directory */
  965. nhcount = 0; /* we didn't find anything there */
  966. #ifdef DEBUG
  967. if (deblog) {
  968. debug(F101,"cmdlin lunet nhcount","",nhcount);
  969. if (nhcount > 0) {
  970. debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
  971. debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
  972. debug(F110,"cmdlin lunet nh_px[0][0]",
  973. nh_px[0][0],0);
  974. }
  975. }
  976. #endif /* DEBUG */
  977. if (nhcount == 0) {
  978. xx = xx_ftp(ftp_host,port);
  979. if (xx < 0 && (haveurl || ftp_cmdlin > 1))
  980. doexit(BAD_EXIT,-1);
  981. } else {
  982. for (i = 0; i < nhcount; i++) {
  983. if (ckstrcmp(nh_p2[i],"tcp/ip",6,0))
  984. continue;
  985. makestr(&ftp_host,nh_p[i]);
  986. debug(F110,"cmdlin calling xx_ftp",ftp_host,0);
  987. if (!quiet)
  988. printf("Trying %s...\n",ftp_host);
  989. if (xx_ftp(ftp_host,port) > -1)
  990. break;
  991. }
  992. }
  993. }
  994. #endif /* NODIAL */
  995. #endif /* NOICP */
  996. if (!ftpisconnected())
  997. doexit(BAD_EXIT,-1);
  998. }
  999. return(0);
  1000. }
  1001. #endif /* NEWFTP */
  1002. #ifdef TNCODE
  1003. if (howcalled == I_AM_TELNET) { /* If I was called as Telnet... */
  1004. while (--xargc > 0) { /* Go through command line words */
  1005. xargv++;
  1006. debug(F111,"cmdlin telnet xargv",*xargv,xargc);
  1007. if (**xargv == '=')
  1008. return(0);
  1009. if (!strcmp(*xargv,"--")) /* getopt() conformance */
  1010. return(0);
  1011. #ifdef VMS
  1012. else if (**xargv == '/')
  1013. continue;
  1014. #endif /* VMS */
  1015. else if (**xargv == '-') { /* Got an option (begins with dash) */
  1016. int xx;
  1017. x = *(*xargv+1); /* Get the option letter */
  1018. debug(F111,"cmdlin telnet args 1",*xargv,xargc);
  1019. xx = dotnarg(x);
  1020. debug(F101,"cmdlin telnet doarg","",xx);
  1021. debug(F111,"cmdlin telnet args 2",*xargv,xargc);
  1022. if (xx < 0) {
  1023. #ifndef NOICP
  1024. if (what == W_COMMAND)
  1025. return(0);
  1026. else
  1027. #endif /* NOICP */
  1028. {
  1029. #ifdef OS2
  1030. sleep(1); /* Give it a chance... */
  1031. #endif /* OS2 */
  1032. doexit(BAD_EXIT,1); /* Go handle option */
  1033. }
  1034. }
  1035. } else { /* No dash must be hostname */
  1036. ckstrncpy(ttname,*xargv,TTNAMLEN+1);
  1037. debug(F110,"cmdlin telnet host",ttname,0);
  1038. #ifndef NOICP
  1039. #ifndef NODIAL
  1040. nhcount = 0; /* Check network directory */
  1041. debug(F101,"cmdlin telnet nnetdir","",nnetdir);
  1042. if (nnetdir > 0) /* If there is a directory... */
  1043. lunet(*xargv); /* Look up the name */
  1044. else /* If no directory */
  1045. nhcount = 0; /* we didn't find anything there */
  1046. #ifdef DEBUG
  1047. if (deblog) {
  1048. debug(F101,"cmdlin telnet lunet nhcount","",nhcount);
  1049. if (nhcount > 0) {
  1050. debug(F110,"cmdlin telnet lunet nh_p[0]",nh_p[0],0);
  1051. debug(F110,"cmdlin telnet lunet nh_p2[0]",nh_p2[0],0);
  1052. debug(F110,"cmdlin telnet lunet nh_px[0][0]",
  1053. nh_px[0][0],0);
  1054. }
  1055. }
  1056. #endif /* DEBUG */
  1057. if (nhcount > 0 && nh_p2[0]) /* If network type specified */
  1058. if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
  1059. nhcount = 0;
  1060. if (nhcount == 1) { /* Still OK, so make substitution */
  1061. ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
  1062. debug(F110,"cmdlin telnet lunet substitution",ttname,0);
  1063. }
  1064. #endif /* NODIAL */
  1065. #endif /* NOICP */
  1066. if (--xargc > 0 && !haveurl) { /* Service from command line? */
  1067. xargv++;
  1068. ckstrncat(ttname,":",TTNAMLEN+1);
  1069. ckstrncat(ttname,*xargv,TTNAMLEN+1);
  1070. debug(F110,"cmdlin telnet host2",ttname,0);
  1071. }
  1072. #ifndef NOICP
  1073. #ifndef NODIAL
  1074. else if (nhcount) { /* No - how about in net directory? */
  1075. if (nh_px[0][0]) {
  1076. ckstrncat(ttname,":",TTNAMLEN+1);
  1077. ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
  1078. }
  1079. }
  1080. #endif /* NODIAL */
  1081. #endif /* NOICP */
  1082. local = 1; /* Try to open the connection */
  1083. nettype = NET_TCPB;
  1084. mdmtyp = -nettype;
  1085. if (ttopen(ttname,&local,mdmtyp,0) < 0) {
  1086. XFATAL("can't open host connection");
  1087. }
  1088. network = 1; /* It's open */
  1089. #ifdef CKLOGDIAL
  1090. dolognet();
  1091. #endif /* CKLOGDIAL */
  1092. #ifndef NOXFER
  1093. reliable = 1; /* It's reliable */
  1094. xreliable = 1; /* ... */
  1095. setreliable = 1;
  1096. #endif /* NOXFER */
  1097. cflg = 1; /* Connect */
  1098. stayflg = 1; /* Stay */
  1099. tn_exit = 1; /* Telnet-like exit condition */
  1100. quiet = 1;
  1101. exitonclose = 1; /* Exit when connection closes */
  1102. #ifndef NOSPL
  1103. if (local) {
  1104. if (nmac) { /* Any macros defined? */
  1105. int k; /* Yes */
  1106. k = mlook(mactab,"on_open",nmac); /* Look this up */
  1107. if (k >= 0) { /* If found, */
  1108. if (dodo(k,ttname,0) > -1) /* set it up, */
  1109. parser(1); /* and execute it */
  1110. }
  1111. }
  1112. }
  1113. #endif /* NOSPL */
  1114. break;
  1115. }
  1116. }
  1117. return(0);
  1118. }
  1119. #endif /* TNCODE */
  1120. #ifdef RLOGCODE
  1121. else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */
  1122. while (--xargc > 0) { /* Go through command line words */
  1123. xargv++;
  1124. debug(F111,"cmdlin rlogin xargv",*xargv,xargc);
  1125. if (**xargv == '=')
  1126. return(0);
  1127. if (!strcmp(*xargv,"--")) /* getopt() conformance */
  1128. return(0);
  1129. #ifdef VMS
  1130. else if (**xargv == '/')
  1131. continue;
  1132. #endif /* VMS */
  1133. else if (**xargv == '-') { /* Got an option (begins with dash) */
  1134. int xx;
  1135. x = *(*xargv+1); /* Get the option letter */
  1136. debug(F111,"cmdlin rlogin args 1",*xargv,xargc);
  1137. xx = dorlgarg(x);
  1138. debug(F101,"cmdlin rlogin doarg","",xx);
  1139. debug(F111,"cmdlin rlogin args 2",*xargv,xargc);
  1140. if (xx < 0) {
  1141. #ifndef NOICP
  1142. if (what == W_COMMAND)
  1143. return(0);
  1144. else
  1145. #endif /* NOICP */
  1146. {
  1147. #ifdef OS2
  1148. sleep(1); /* Give it a chance... */
  1149. #endif /* OS2 */
  1150. doexit(BAD_EXIT,1); /* Go handle option */
  1151. }
  1152. }
  1153. } else { /* No dash must be hostname */
  1154. ckstrncpy(ttname,*xargv,TTNAMLEN+1);
  1155. debug(F110,"cmdlin rlogin host",ttname,0);
  1156. #ifndef NOICP
  1157. #ifndef NODIAL
  1158. nhcount = 0; /* Check network directory */
  1159. debug(F101,"cmdlin rlogin nnetdir","",nnetdir);
  1160. if (nnetdir > 0) /* If there is a directory... */
  1161. lunet(*xargv); /* Look up the name */
  1162. else /* If no directory */
  1163. nhcount = 0; /* we didn't find anything there */
  1164. #ifdef DEBUG
  1165. if (deblog) {
  1166. debug(F101,"cmdlin rlogin lunet nhcount","",nhcount);
  1167. if (nhcount > 0) {
  1168. debug(F110,"cmdlin rlogin lunet nh_p[0]",nh_p[0],0);
  1169. debug(F110,"cmdlin rlogin lunet nh_p2[0]",nh_p2[0],0);
  1170. debug(F110,"cmdlin rlogin lunet nh_px[0][0]",
  1171. nh_px[0][0],0);
  1172. }
  1173. }
  1174. #endif /* DEBUG */
  1175. if (nhcount > 0 && nh_p2[0]) /* If network type specified */
  1176. if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
  1177. nhcount = 0;
  1178. if (nhcount == 1) { /* Still OK, so make substitution */
  1179. ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
  1180. debug(F110,"cmdlin rlogin lunet substitution",ttname,0);
  1181. }
  1182. #endif /* NODIAL */
  1183. #endif /* NOICP */
  1184. if (!haveurl) { /* Service from command line? */
  1185. ckstrncat(ttname,":login",TTNAMLEN+1);
  1186. debug(F110,"cmdlin rlogin host2",ttname,0);
  1187. }
  1188. local = 1; /* Try to open the connection */
  1189. nettype = NET_TCPB;
  1190. mdmtyp = -nettype;
  1191. if (ttopen(ttname,&local,mdmtyp,0) < 0) {
  1192. XFATAL("can't open host connection");
  1193. }
  1194. network = 1; /* It's open */
  1195. #ifdef CKLOGDIAL
  1196. dolognet();
  1197. #endif /* CKLOGDIAL */
  1198. #ifndef NOXFER
  1199. reliable = 1; /* It's reliable */
  1200. xreliable = 1; /* ... */
  1201. setreliable = 1;
  1202. #endif /* NOXFER */
  1203. cflg = 1; /* Connect */
  1204. stayflg = 1; /* Stay */
  1205. tn_exit = 1; /* Telnet-like exit condition */
  1206. quiet = 1;
  1207. exitonclose = 1; /* Exit when connection closes */
  1208. #ifndef NOSPL
  1209. if (local) {
  1210. if (nmac) { /* Any macros defined? */
  1211. int k; /* Yes */
  1212. k = mlook(mactab,"on_open",nmac); /* Look this up */
  1213. if (k >= 0) { /* If found, */
  1214. if (dodo(k,ttname,0) > -1) /* set it up, */
  1215. parser(1); /* and execute it */
  1216. }
  1217. }
  1218. }
  1219. #endif /* NOSPL */
  1220. break;
  1221. }
  1222. }
  1223. return(0);
  1224. }
  1225. #endif /* RLOGCODE */
  1226. #endif /* TCPSOCKET */
  1227. #ifdef SSHBUILTIN
  1228. if (howcalled == I_AM_SSH) { /* If I was called as SSH... */
  1229. extern char * ssh_hst, * ssh_cmd, * ssh_prt;
  1230. debug(F100,"ssh personality","",0);
  1231. #ifdef CK_URL
  1232. if (haveurl) {
  1233. makestr(&ssh_hst,g_url.hos);
  1234. makestr(&ssh_prt,g_url.svc);
  1235. ckstrncpy(ttname,ssh_hst,TTNAMLEN+1);
  1236. ckstrncat(ttname,":",TTNAMLEN+1);
  1237. ckstrncat(ttname,ssh_prt,TTNAMLEN+1);
  1238. }
  1239. else
  1240. #endif /* CK_URL */
  1241. {
  1242. while (--xargc > 0) { /* Go through command line words */
  1243. xargv++;
  1244. debug(F111,"cmdlin ssh xargv",*xargv,xargc);
  1245. if (**xargv == '=')
  1246. return(0);
  1247. if (!strcmp(*xargv,"--")) /* getopt() conformance */
  1248. return(0);
  1249. #ifdef VMS
  1250. else if (**xargv == '/')
  1251. continue;
  1252. #endif /* VMS */
  1253. /* Got an option (begins with dash) */
  1254. else if (**xargv == '-') {
  1255. int xx;
  1256. x = *(*xargv+1); /* Get the option letter */
  1257. debug(F111,"cmdlin args 1",*xargv,xargc);
  1258. xx = dossharg(x);
  1259. debug(F101,"cmdlin doarg","",xx);
  1260. debug(F111,"cmdlin args 2",*xargv,xargc);
  1261. if (xx < 0) {
  1262. #ifndef NOICP
  1263. if (what == W_COMMAND)
  1264. return(0);
  1265. else
  1266. #endif /* NOICP */
  1267. {
  1268. #ifdef OS2
  1269. sleep(1); /* Give it a chance... */
  1270. #endif /* OS2 */
  1271. doexit(BAD_EXIT,1); /* Go handle option */
  1272. }
  1273. }
  1274. } else { /* No dash must be hostname */
  1275. ckstrncpy(ttname,*xargv,TTNAMLEN+1);
  1276. makestr(&ssh_hst,ttname);
  1277. debug(F110,"cmdlin ssh host",ttname,0);
  1278. #ifndef NOICP
  1279. #ifndef NODIAL
  1280. nhcount = 0; /* Check network directory */
  1281. debug(F101,"cmdlin nnetdir","",nnetdir);
  1282. if (nnetdir > 0) /* If there is a directory... */
  1283. lunet(*xargv); /* Look up the name */
  1284. else /* If no directory */
  1285. nhcount = 0; /* we didn't find anything there */
  1286. #ifdef DEBUG
  1287. if (deblog) {
  1288. debug(F101,"cmdlin lunet nhcount","",nhcount);
  1289. if (nhcount > 0) {
  1290. debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
  1291. debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
  1292. debug(F110,
  1293. "cmdlin lunet nh_px[0][0]",nh_px[0][0],0);
  1294. }
  1295. }
  1296. #endif /* DEBUG */
  1297. /* If network type specified */
  1298. /* it must be TCP/IP */
  1299. if (nhcount > 0 && nh_p2[0])
  1300. if (ckstrcmp(nh_p2[0],"tcp/ip",6,0))
  1301. nhcount = 0;
  1302. if (nhcount == 1) { /* Still OK, so make substitution */
  1303. ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
  1304. makestr(&ssh_hst,ttname);
  1305. debug(F110,"cmdlin lunet substitution",ttname,0);
  1306. }
  1307. #endif /* NODIAL */
  1308. #endif /* NOICP */
  1309. /* Service from command line? */
  1310. if (--xargc > 0 && !haveurl) {
  1311. xargv++;
  1312. ckstrncat(ttname,":",TTNAMLEN+1);
  1313. ckstrncat(ttname,*xargv,TTNAMLEN+1);
  1314. makestr(&ssh_prt,*xargv);
  1315. debug(F110,"cmdlin telnet host2",ttname,0);
  1316. }
  1317. #ifdef COMMENT
  1318. /* Do not substitute net dir service for ssh port */
  1319. #ifndef NOICP
  1320. #ifndef NODIAL
  1321. /* No - how about in net directory? */
  1322. else if (nhcount) {
  1323. if (nh_px[0][0]) {
  1324. ckstrncat(ttname,":",TTNAMLEN+1);
  1325. ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
  1326. makestr(&ssh_prt,nh_px[0][0]);
  1327. }
  1328. }
  1329. #endif /* NODIAL */
  1330. #endif /* NOICP */
  1331. #endif /* COMMENT */
  1332. break;
  1333. }
  1334. }
  1335. }
  1336. local = 1; /* Try to open the connection */
  1337. nettype = NET_SSH;
  1338. mdmtyp = -nettype;
  1339. if (ttopen(ttname,&local,mdmtyp,0) < 0) {
  1340. XFATAL("can't open host connection");
  1341. }
  1342. network = 1; /* It's open */
  1343. #ifdef CKLOGDIAL
  1344. dolognet();
  1345. #endif /* CKLOGDIAL */
  1346. #ifndef NOXFER
  1347. reliable = 1; /* It's reliable */
  1348. xreliable = 1; /* ... */
  1349. setreliable = 1;
  1350. #endif /* NOXFER */
  1351. cflg = 1; /* Connect */
  1352. stayflg = 1; /* Stay */
  1353. tn_exit = 1; /* Telnet-like exit condition */
  1354. quiet = 1;
  1355. exitonclose = 1; /* Exit when connection closes */
  1356. #ifndef NOSPL
  1357. if (local) {
  1358. if (nmac) { /* Any macros defined? */
  1359. int k; /* Yes */
  1360. k = mlook(mactab,"on_open",nmac); /* Look this up */
  1361. if (k >= 0) { /* If found, */
  1362. if (dodo(k,ttname,0) > -1) /* set it up, */
  1363. parser(1); /* and execute it */
  1364. }
  1365. }
  1366. }
  1367. #endif /* NOSPL */
  1368. return(0);
  1369. }
  1370. #endif /* SSHBUILTIN */
  1371. if (howcalled == I_AM_SSHSUB)
  1372. return(0);
  1373. /*
  1374. From here down: We were called as "kermit" or "iksd".
  1375. If we were started directly from a Kermit script file,
  1376. the filename of the script is in argv[1], so skip past it.
  1377. */
  1378. if (xargc > 1) {
  1379. int n = 1;
  1380. if (*xargv[1] != '-') {
  1381. #ifdef KERBANG
  1382. /* If we were started with a Kerbang script, the script */
  1383. /* arguments were already picked up in prescan / cmdini() */
  1384. /* and there is nothing here for us anyway. */
  1385. if (!strcmp(xargv[1],"+"))
  1386. return(0);
  1387. #endif /* KERBANG */
  1388. if (cfilef) { /* Command file found in prescan() */
  1389. xargc -= n; /* Skip past it */
  1390. xargv += n;
  1391. cfilef = 0;
  1392. debug(F101,"cmdlin cfilef set to 0","",cfilef);
  1393. }
  1394. }
  1395. }
  1396. /*
  1397. Regular Unix-style command line parser, mostly conforming with 'A Proposed
  1398. Command Syntax Standard for Unix Systems', Hemenway & Armitage, Unix/World,
  1399. Vol.1, No.3, 1984.
  1400. */
  1401. while (--xargc > 0) { /* Go through command line words */
  1402. xargv++;
  1403. debug(F111,"cmdlin xargv",*xargv,xargc);
  1404. if (**xargv == '=')
  1405. return(0);
  1406. if (!strcmp(*xargv,"--")) /* getopt() conformance */
  1407. return(0);
  1408. #ifdef VMS
  1409. else if (**xargv == '/')
  1410. continue;
  1411. #endif /* VMS */
  1412. else if (**xargv == '-') { /* Got an option (begins with dash) */
  1413. int xx;
  1414. x = *(*xargv+1); /* Get the option letter */
  1415. debug(F111,"cmdlin args 1",*xargv,xargc);
  1416. xx = doarg(x);
  1417. debug(F101,"cmdlin doarg","",xx);
  1418. debug(F111,"cmdlin args 2",*xargv,xargc);
  1419. if (xx < 0) {
  1420. #ifndef NOICP
  1421. if (what == W_COMMAND)
  1422. return(0);
  1423. else
  1424. #endif /* NOICP */
  1425. {
  1426. #ifdef OS2
  1427. sleep(1); /* Give it a chance... */
  1428. #endif /* OS2 */
  1429. doexit(BAD_EXIT,1); /* Go handle option */
  1430. }
  1431. }
  1432. } else if (!haveurl) { /* No dash where expected */
  1433. char xbuf[32];
  1434. char buf[128];
  1435. int k;
  1436. k = ckstrncpy(xbuf,*xargv,40);
  1437. if (k > 30) {
  1438. xbuf[30] = '.';
  1439. xbuf[29] = '.';
  1440. xbuf[28] = '.';
  1441. }
  1442. xbuf[31] = NUL;
  1443. ckmakmsg(buf,
  1444. 128,
  1445. "invalid command-line option, type \"",
  1446. myname,
  1447. " -h\" for help",
  1448. NULL
  1449. );
  1450. fatal2(xbuf,buf);
  1451. }
  1452. }
  1453. #ifdef DEBUG
  1454. if (deblog) {
  1455. #ifndef NOICP
  1456. debug(F101,"cmdlin what","",what);
  1457. #endif /* NOICP */
  1458. debug(F101,"cmdlin action","",action);
  1459. #ifndef NOXFER
  1460. debug(F101,"cmdlin stdouf","",stdouf);
  1461. #endif /* NOXFER */
  1462. }
  1463. #endif /* DEBUG */
  1464. #ifdef NOICP
  1465. if (!action && !cflg && !cnflg) {
  1466. debug(F100,"cmdlin NOICP fatal no action","",0);
  1467. XFATAL("?No actions specified on command line");
  1468. }
  1469. #else
  1470. if (inserver && what == 0) { /* Internet Kermit server checks */
  1471. if (local || (action != 0 && action != 'x')) {
  1472. if (local)
  1473. printf("local\r\n");
  1474. if (action)
  1475. printf("action=%c\r\n",action);
  1476. debug(F100,"cmdlin fatal 1","",0);
  1477. XFATAL("No actions or connections allowed with -A");
  1478. }
  1479. }
  1480. #endif /* NOICP */
  1481. #ifndef NOLOCAL
  1482. if (!local) {
  1483. if ((action == 'c') || (cflg != 0)) {
  1484. debug(F100,"cmdlin fatal 2","",0);
  1485. XFATAL("-l or -j or -X required");
  1486. }
  1487. }
  1488. #endif /* NOLOCAL */
  1489. #ifndef NOXFER
  1490. if (*cmarg2 != 0) {
  1491. if ((action != 's') && (action != 'r') && (action != 'v')) {
  1492. debug(F100,"cmdlin fatal 3","",0);
  1493. XFATAL("-a without -s, -r, or -g");
  1494. }
  1495. if (action == 'r' || action == 'v') {
  1496. #ifdef CK_TMPDIR
  1497. if (isdir(cmarg2)) { /* -a is a directory */
  1498. if (!zchdir(cmarg2)) { /* try to change to it */
  1499. debug(F100,"cmdlin fatal 4","",0);
  1500. XFATAL("can't change to '-a' directory");
  1501. } else cmarg2 = "";
  1502. } else
  1503. #endif /* CK_TMPDIR */
  1504. if (zchko(cmarg2) < 0) {
  1505. debug(F100,"cmdlin fatal 5","",0);
  1506. XFATAL("write access to -a file denied");
  1507. }
  1508. }
  1509. }
  1510. if ((action == 'v') && (stdouf) && (!local)) {
  1511. if (is_a_tty(1)) {
  1512. debug(F100,"cmdlin fatal 6","",0);
  1513. XFATAL("unredirected -k can only be used in local mode");
  1514. }
  1515. }
  1516. if ((action == 's') || (action == 'v') ||
  1517. (action == 'r') || (action == 'x')) {
  1518. if (local)
  1519. displa = 1;
  1520. if (stdouf) {
  1521. displa = 0;
  1522. quiet = 1;
  1523. }
  1524. }
  1525. if (quiet) displa = 0; /* No display if quiet requested */
  1526. #endif /* NOXFER */
  1527. #ifdef DEBUG
  1528. if (action)
  1529. debug(F000,"cmdlin returns action","",action);
  1530. else
  1531. debug(F101,"cmdlin returns action","",action);
  1532. #endif /* DEBUG */
  1533. return(action); /* Then do any requested protocol */
  1534. }
  1535. /* Extended argument parsing: --keyword[:value] (or =value) */
  1536. /*
  1537. XA_xxxx symbols are defined in ckuusr.h.
  1538. If you add a new one, also remember to update doshow(),
  1539. SHXOPT section, in ckuus5.c.
  1540. */
  1541. struct keytab xargtab[] = {
  1542. #ifdef CK_LOGIN
  1543. { "anonymous", XA_ANON, CM_ARG|CM_PRE },
  1544. #endif /* CK_LOGIN */
  1545. { "bannerfile", XA_BAFI, CM_ARG },
  1546. { "cdfile", XA_CDFI, CM_ARG },
  1547. { "cdmessage", XA_CDMS, CM_ARG },
  1548. { "cdmsg", XA_CDMS, CM_ARG|CM_INV },
  1549. #ifdef KUI
  1550. { "changedim", XA_CHGD, CM_PRE },
  1551. #endif /* KUI */
  1552. #ifndef NOCSETS
  1553. { "charset", XA_CSET, CM_ARG|CM_PRE },
  1554. #endif /* NOCSETS */
  1555. #ifdef IKSDB
  1556. { "database", XA_DBAS, CM_ARG|CM_PRE },
  1557. { "dbfile", XA_DBFI, CM_ARG|CM_PRE },
  1558. #endif /* IKSDB */
  1559. #ifdef KUI
  1560. { "facename", XA_FNAM, CM_ARG|CM_PRE|CM_INV },
  1561. { "fontname", XA_FNAM, CM_ARG|CM_PRE },
  1562. { "fontsize", XA_FSIZ, CM_ARG|CM_PRE },
  1563. #endif /* KUI */
  1564. #ifdef COMMENT
  1565. #ifdef NEWFTP
  1566. { "ftp", XA_FTP, CM_ARG },
  1567. #endif /* NEWFTP */
  1568. #endif /* COMMENT */
  1569. #ifndef NOLOCAL
  1570. #ifdef OS2
  1571. { "height", XA_ROWS, CM_ARG|CM_PRE },
  1572. #endif /* OS2 */
  1573. #endif /* NOLOCAL */
  1574. { "help", XA_HELP, 0 },
  1575. #ifndef NOHELP
  1576. { "helpfile", XA_HEFI, CM_ARG },
  1577. #endif /* NOHELP */
  1578. #ifdef CK_LOGIN
  1579. { "initfile", XA_ANFI, CM_ARG|CM_PRE },
  1580. #endif /* CK_LOGIN */
  1581. #ifdef OS2
  1582. { "lockdown", XA_LOCK, CM_PRE },
  1583. #ifdef KUI
  1584. { "maximize", XA_WMAX, CM_PRE },
  1585. { "minimize", XA_WMIN, CM_PRE },
  1586. { "nobars", XA_NOBAR, CM_PRE },
  1587. { "noclose" , XA_NOCLOSE, CM_PRE },
  1588. #endif /* KUI */
  1589. { "noescape", XA_NOESCAPE, CM_PRE },
  1590. #endif /* OS2 */
  1591. { "nointerrupts",XA_NOIN, CM_PRE },
  1592. { "nolocale", XA_NOLOCALE, CM_PRE },
  1593. #ifdef KUI
  1594. { "nomenubar", XA_NOMN, CM_PRE },
  1595. #endif /* KUI */
  1596. { "noperms", XA_NPRM, 0 },
  1597. #ifndef NOPUSH
  1598. { "nopush", XA_NOPUSH, CM_PRE },
  1599. #endif /* NOPUSH */
  1600. #ifdef OS2
  1601. { "noscroll", XA_NOSCROLL, CM_PRE },
  1602. #endif /* OS2 */
  1603. #ifdef KUI
  1604. { "nostatusbar", XA_NOSB, CM_PRE },
  1605. { "notoolbar", XA_NOTB, CM_PRE },
  1606. #endif /* KUI */
  1607. #ifdef COMMENT
  1608. { "password", XA_PASS, CM_ARG|CM_INV },
  1609. #endif /* COMMENT */
  1610. #ifdef CK_LOGIN
  1611. #ifndef NOXFER
  1612. #ifdef CK_PERM
  1613. { "permissions", XA_PERM, CM_ARG|CM_PRE },
  1614. { "perms", XA_PERM, CM_ARG|CM_PRE|CM_INV },
  1615. #endif /* CK_PERM */
  1616. #endif /* NOXFER */
  1617. #ifdef UNIX
  1618. { "privid", XA_PRIV, CM_ARG|CM_PRE },
  1619. #endif /* UNIX */
  1620. #ifndef NOLOCAL
  1621. #ifndef NOCSETS
  1622. { "rcharset", XA_CSET, CM_ARG|CM_PRE|CM_INV },
  1623. #endif /* NOCSETS */
  1624. #endif /* NOLOCAL */
  1625. #ifdef UNIX
  1626. { "root", XA_ROOT, CM_ARG|CM_PRE },
  1627. #else /* UNIX */
  1628. #ifdef CKROOT
  1629. { "root", XA_ROOT, CM_ARG|CM_PRE },
  1630. #endif /* CKROOT */
  1631. #endif /* UNIX */
  1632. #ifdef KUI
  1633. { "scalefont", XA_SCALE, CM_PRE },
  1634. #endif /* KUI */
  1635. #ifdef COMMENT
  1636. #ifdef SSHBUILTIN
  1637. { "ssh", XA_SSH, CM_ARG },
  1638. #endif /* SSHBUILTIN */
  1639. #endif /* COMMENT */
  1640. #ifdef CKSYSLOG
  1641. { "syslog", XA_SYSL, CM_ARG|CM_PRE },
  1642. #endif /* CKSYSLOG */
  1643. #ifndef NOLOCAL
  1644. #ifdef COMMENT
  1645. #ifdef TNCODE
  1646. { "telnet", XA_TEL, CM_ARG },
  1647. #endif /* TNCODE */
  1648. #endif /* COMMENT */
  1649. { "termtype", XA_TERM, CM_ARG|CM_PRE },
  1650. #endif /* NOLOCAL */
  1651. { "timeout", XA_TIMO, CM_ARG|CM_PRE },
  1652. #ifndef NOLOCAL
  1653. #ifdef OS2
  1654. { "title", XA_TITL, CM_ARG },
  1655. #endif /* OS2 */
  1656. #ifdef UNIX
  1657. { "unbuffered", XA_UNBUF, 0 },
  1658. #endif /* UNIX */
  1659. #ifndef NOSPL
  1660. { "user", XA_USER, CM_ARG },
  1661. #endif /* NOSPL */
  1662. #endif /* NOLOCAL */
  1663. { "userfile", XA_USFI, CM_ARG|CM_PRE },
  1664. { "version", XA_VERS, 0 },
  1665. #ifndef NOLOCAL
  1666. #ifdef OS2
  1667. { "width", XA_COLS, CM_ARG|CM_PRE },
  1668. #endif /* OS2 */
  1669. #endif /* NOLOCAL */
  1670. #ifdef CKWTMP
  1671. { "wtmpfile", XA_WTFI, CM_ARG|CM_PRE },
  1672. { "wtmplog", XA_WTMP, CM_ARG|CM_PRE },
  1673. #endif /* CKWTMP */
  1674. #endif /* CK_LOGIN */
  1675. { "xferfile", XA_IKFI, CM_ARG|CM_PRE },
  1676. { "xferlog", XA_IKLG, CM_ARG|CM_PRE },
  1677. #ifndef NOLOCAL
  1678. #ifdef KUI
  1679. { "xpos", XA_XPOS, CM_ARG|CM_PRE },
  1680. { "ypos", XA_YPOS, CM_ARG|CM_PRE },
  1681. #endif /* KUI */
  1682. #endif /* NOLOCAL */
  1683. {"", 0, 0 }
  1684. };
  1685. int nxargs = sizeof(xargtab)/sizeof(struct keytab) - 1;
  1686. static struct keytab oktab[] = {
  1687. { "0", 0, 0 },
  1688. { "1", 1, 0 },
  1689. { "2", 2, 0 },
  1690. { "3", 3, 0 },
  1691. { "4", 4, 0 },
  1692. { "5", 5, 0 },
  1693. { "6", 6, 0 },
  1694. { "7", 7, 0 },
  1695. { "8", 8, 0 },
  1696. { "9", 9, 0 },
  1697. { "false", 0, 0 },
  1698. { "no", 0, 0 },
  1699. { "off", 0, 0 },
  1700. { "ok", 1, 0 },
  1701. { "on", 1, 0 },
  1702. { "true", 1, 0 },
  1703. { "yes", 1, 0 }
  1704. };
  1705. static int noktab = sizeof(oktab)/sizeof(struct keytab);
  1706. #define XARGBUFL 32
  1707. char * xopthlp[XA_MAX+1]; /* Extended option help */
  1708. char * xarghlp[XA_MAX+1]; /* Extended argument for option */
  1709. static VOID
  1710. inixopthlp() {
  1711. int i, j;
  1712. for (i = 0; i <= XA_MAX; i++) { /* Initialize all to null */
  1713. xopthlp[i] = NULL;
  1714. xarghlp[i] = NULL;
  1715. }
  1716. for (i = 0; i < nxargs; i++) { /* Then for each defined keyword */
  1717. j = xargtab[i].kwval; /* index by associated value */
  1718. if (j < 0 || j > XA_MAX)
  1719. continue;
  1720. switch (j) {
  1721. #ifdef CK_LOGIN
  1722. case XA_ANON: /* "--anonymous" */
  1723. xopthlp[j] = "--anonymous:{on,off} [IKSD only]";
  1724. xarghlp[j] = "Whether to allow anonymous IKSD logins";
  1725. break;
  1726. #ifdef UNIX
  1727. case XA_PRIV:
  1728. xopthlp[j] = "--privid:{on,off} [IKSD only]";
  1729. xarghlp[j] = "Whether to allow privileged IDs to login to IKSD";
  1730. break;
  1731. #endif /* UNIX */
  1732. #endif /* CK_LOGIN */
  1733. case XA_BAFI: /* "--bannerfile" */
  1734. xopthlp[j] = "--bannerfile:<filename>";
  1735. xarghlp[j] = "File to display upon startup or IKSD login";
  1736. break;
  1737. case XA_CDFI: /* "--cdfile" */
  1738. xopthlp[j] = "--cdfile:<filename>";
  1739. xarghlp[j] = "File to display when server changes directory";
  1740. break;
  1741. case XA_CDMS: /* "--cdmessage" */
  1742. xopthlp[j] = "--cdmessage:{on,off}";
  1743. xarghlp[j] = "Whether to display CD message file";
  1744. break;
  1745. case XA_HELP: /* "--help" */
  1746. xopthlp[j] = "--help";
  1747. xarghlp[j] = "Print this help text about extended options";
  1748. break;
  1749. case XA_HEFI: /* "--help" */
  1750. xopthlp[j] = "--helpfile:<filename>";
  1751. xarghlp[j] = "File containing custom info for HELP command";
  1752. break;
  1753. case XA_IKFI: /* "--xferfile" */
  1754. xopthlp[j] = "--xferfile:<filename> [IKSD only]";
  1755. xarghlp[j] = "Name of ftpd-like logfile.";
  1756. break;
  1757. case XA_IKLG: /* "--xferlog" */
  1758. xopthlp[j] = "--xferlog:{on,off} [IKSD only]";
  1759. xarghlp[j] = "Whether to keep an ftpd-like logfile.";
  1760. break;
  1761. #ifdef CK_LOGIN
  1762. case XA_ANFI: /* "--initfile" */
  1763. xopthlp[j] = "--initfile:<filename> [IKSD only]";
  1764. xarghlp[j] = "Initialization file for anonymous users.";
  1765. break;
  1766. #ifdef CK_PERM
  1767. case XA_PERM: /* "--permissions" */
  1768. xopthlp[j] = "--permissions:<octalnum> [IKSD only]";
  1769. xarghlp[j] = "Permissions for files uploaded by anonymous users.";
  1770. break;
  1771. #endif /* CK_PERM */
  1772. #ifdef UNIX
  1773. case XA_ROOT: /* "--root" */
  1774. xopthlp[j] = "--root:<directory> [IKSD only]";
  1775. xarghlp[j] = "File-system root for anonymous users.";
  1776. break;
  1777. #else /* UNIX */
  1778. #ifdef CKROOT
  1779. case XA_ROOT: /* "--root" */
  1780. xopthlp[j] = "--root:<directory> [IKSD only]";
  1781. xarghlp[j] = "File-system root for anonymous users.";
  1782. break;
  1783. #endif /* CKROOT */
  1784. #endif /* UNIX */
  1785. #endif /* CK_LOGIN */
  1786. #ifdef CKSYSLOG
  1787. case XA_SYSL: /* "--syslog" */
  1788. xopthlp[j] = "--syslog:<digit> [IKSD only]";
  1789. xarghlp[j] = "Syslog recording level, 0-6.";
  1790. break;
  1791. #endif /* CKSYSLOG */
  1792. case XA_USFI: /* "--userfile" */
  1793. xopthlp[j] = "--userfile:<filename> [IKSD only]";
  1794. xarghlp[j] = "Forbidden user file.";
  1795. break;
  1796. #ifdef CKWTMP
  1797. case XA_WTFI: /* "--wtmpfile" */
  1798. xopthlp[j] = "--wtmpfile:<filename> [IKSD only]";
  1799. xarghlp[j] = "Name of wtmp logfile.";
  1800. break;
  1801. case XA_WTMP: /* "--wtmplog" */
  1802. xopthlp[j] = "--wtmplog:{on,off} [IKSD only]";
  1803. xarghlp[j] = "Whether to keep a wtmp logfile.";
  1804. break;
  1805. #endif /* CKWTMP */
  1806. #ifdef CK_LOGIN
  1807. case XA_TIMO: /* "--timeout" */
  1808. xopthlp[j] = "--timeout:<seconds> [IKSD only]";
  1809. xarghlp[j] =
  1810. "How long to wait for login before closing the connection.";
  1811. break;
  1812. #endif /* CK_LOGIN */
  1813. case XA_NOIN:
  1814. xopthlp[j] = "--nointerrupts";
  1815. xarghlp[j] = "Disable keyboard interrupts.";
  1816. break;
  1817. #ifdef UNIX
  1818. case XA_UNBUF:
  1819. xopthlp[j] = "--unbuffered";
  1820. xarghlp[j] = "Force unbuffered console i/o.";
  1821. break;
  1822. #endif /* UNIX */
  1823. #ifdef IKSDB
  1824. case XA_DBAS:
  1825. xopthlp[j] = "--database:{on,off}";
  1826. xarghlp[j] = "Enable/Disable IKSD database (IKSD only)";
  1827. break;
  1828. case XA_DBFI:
  1829. xopthlp[j] = "--dbfile:<filename>";
  1830. xarghlp[j] = "Specify IKSD database file (IKSD only)";
  1831. break;
  1832. #endif /* IKSDB */
  1833. #ifdef CK_PERMS
  1834. case XA_NPRM:
  1835. xopthlp[j] = "--noperms";
  1836. xarghlp[j] = "Disable file-transfer Permissions attribute.";
  1837. break;
  1838. #endif /* CK_PERMS */
  1839. #ifdef KUI
  1840. case XA_CHGD:
  1841. xopthlp[j] = "--changedim";
  1842. xarghlp[j] = "Change Dimension on Window Resize";
  1843. case XA_SCALE:
  1844. xopthlp[j] = "--scalefont";
  1845. xarghlp[j] = "Scale Font on Window Resize";
  1846. case XA_WMAX:
  1847. xopthlp[j] = "--maximize";
  1848. xarghlp[j] = "start K95G window maximized.";
  1849. break;
  1850. case XA_WMIN:
  1851. xopthlp[j] = "--minimize";
  1852. xarghlp[j] = "start K95G window minimized.";
  1853. break;
  1854. case XA_XPOS:
  1855. xopthlp[j] = "--xpos:n";
  1856. xarghlp[j] = "X-coordinate of window position (number).";
  1857. break;
  1858. case XA_YPOS:
  1859. xopthlp[j] = "--ypos:n";
  1860. xarghlp[j] = "Y-coordinate of window position (number).";
  1861. break;
  1862. case XA_FNAM:
  1863. xopthlp[j] = "--fontname:s (or --facename:s)";
  1864. xarghlp[j] = "Font/typeface name: string with _ replacing blank.";
  1865. break;
  1866. case XA_FSIZ:
  1867. xopthlp[j] = "--fontsize:n";
  1868. xarghlp[j] = "Font point size (number).";
  1869. break;
  1870. case XA_NOMN:
  1871. xopthlp[j] = "--nomenubar";
  1872. xarghlp[j] = "No Menu Bar";
  1873. break;
  1874. case XA_NOTB:
  1875. xopthlp[j] = "--notoolbar";
  1876. xarghlp[j] = "No Tool Bar";
  1877. break;
  1878. case XA_NOSB:
  1879. xopthlp[j] = "--nostatusbar";
  1880. xarghlp[j] = "No Status Bar";
  1881. break;
  1882. case XA_NOBAR:
  1883. xopthlp[j] = "--nobars";
  1884. xarghlp[j] = "No Menu, Status, or Tool Bars";
  1885. break;
  1886. #endif /* KUI */
  1887. #ifndef NOPUSH
  1888. case XA_NOPUSH:
  1889. xopthlp[j] = "--nopush";
  1890. xarghlp[j] = "Disable external command execution.";
  1891. break;
  1892. #endif /* NOPUSH */
  1893. #ifdef OS2
  1894. case XA_LOCK:
  1895. xopthlp[j] = "--lockdown";
  1896. xarghlp[j] = "Enable all lockdown options.";
  1897. break;
  1898. case XA_NOCLOSE:
  1899. xopthlp[j] = "--noclose";
  1900. xarghlp[j] = "Disable Close Window and Menu Exit.";
  1901. break;
  1902. case XA_NOSCROLL:
  1903. xopthlp[j] = "--noscroll";
  1904. xarghlp[j] = "Disable scrollback operations.";
  1905. break;
  1906. case XA_NOESCAPE:
  1907. xopthlp[j] = "--noescape";
  1908. xarghlp[j] = "Disable escape from connect mode.";
  1909. break;
  1910. case XA_ROWS:
  1911. xopthlp[j] = "--height:n";
  1912. xarghlp[j] = "Screen height (number of rows).";
  1913. break;
  1914. case XA_COLS:
  1915. xopthlp[j] = "--width:n";
  1916. xarghlp[j] = "Screen width (number of columns).";
  1917. break;
  1918. case XA_TITL:
  1919. xopthlp[j] = "--title:string";
  1920. xarghlp[j] = "Window Title.";
  1921. break;
  1922. #endif /* OS2 */
  1923. case XA_CSET:
  1924. xopthlp[j] = "--rcharset:name";
  1925. xarghlp[j] = "Name of remote terminal character set.";
  1926. break;
  1927. case XA_TERM:
  1928. xopthlp[j] = "--termtype:name";
  1929. #ifdef OS2
  1930. xarghlp[j] = "Choose terminal emulation.";
  1931. #else
  1932. xarghlp[j] = "Choose terminal type.";
  1933. #endif /* OS2 */
  1934. break;
  1935. case XA_USER:
  1936. xopthlp[j] = "--user:name";
  1937. #ifndef NETCONN
  1938. xarghlp[j] = "Username (for network login)";
  1939. #else
  1940. xarghlp[j] = "Username.";
  1941. #endif /* NETCONN */
  1942. break;
  1943. #ifdef HAVE_LOCALE
  1944. case XA_NOLOCALE:
  1945. xopthlp[j] = "--nolocale";
  1946. xarghlp[j] = "Disable use of locale for messages and strings.";
  1947. break;
  1948. #endif /* HAVE_LOCALE */
  1949. }
  1950. }
  1951. }
  1952. VOID
  1953. iniopthlp() {
  1954. int i;
  1955. for (i = 0; i < 128; i++) {
  1956. optact[i] = 0;
  1957. switch(i) {
  1958. #ifdef OS2
  1959. case '#': /* K95 Startup Flags */
  1960. opthlp[i] = "Kermit 95 Startup Flags";
  1961. arghlp[i] = "\n"\
  1962. " 1 - turn off Win95 special fixes\n"\
  1963. " 2 - do not load optional network dlls\n"\
  1964. " 4 - do not load optional tapi dlls\n"\
  1965. " 8 - do not load optional kerberos dlls\n"\
  1966. " 16 - do not load optional zmodem dlls\n"\
  1967. " 32 - use stdin for input instead of the console\n"\
  1968. " 64 - use stdout for output instead of the console\n"\
  1969. " 128 - do not terminate process in response to Session Logoff";
  1970. break;
  1971. #endif /* OS2 */
  1972. case '0': /* In the middle */
  1973. opthlp[i] =
  1974. "100% transparent CONNECT mode for \"in-the-middle\" operation";
  1975. arghlp[i] = NULL;
  1976. break;
  1977. case '8':
  1978. opthlp[i] = "Connection is 8-bit clean";
  1979. arghlp[i] = NULL;
  1980. break;
  1981. #ifdef NEWFTP
  1982. case '9':
  1983. opthlp[i] = "Make a connection to an FTP server";
  1984. arghlp[i] = "IP-address-or-hostname[:optional-TCP-port]";
  1985. break;
  1986. #endif /* NEWFTP */
  1987. #ifdef IKSD
  1988. case 'A':
  1989. opthlp[i] = "Kermit is to be started as an Internet service";
  1990. #ifdef NT
  1991. arghlp[i] = " socket handle of incoming connection";
  1992. #else /* NT */
  1993. arghlp[i] = NULL;
  1994. #endif /* NT */
  1995. break;
  1996. #endif /* IKSD */
  1997. case 'B': opthlp[i] =
  1998. "Kermit is running in Batch or Background (no controlling terminal)";
  1999. break;
  2000. #ifndef NOSPL
  2001. case 'C':
  2002. opthlp[i] = "Interactive-mode Commands to be executed";
  2003. arghlp[i] = "Commands separated by commas, list in doublequotes";
  2004. break;
  2005. #endif /* NOSPL */
  2006. case 'D':
  2007. opthlp[i] = "Delay before starting to send";
  2008. arghlp[i] = "Number of seconds";
  2009. break;
  2010. case 'E':
  2011. opthlp[i] = "Exit automatically when connection closes";
  2012. arghlp[i] = NULL;
  2013. break;
  2014. #ifdef TCPSOCKET
  2015. case 'F':
  2016. opthlp[i] = "Use an existing TCP connection";
  2017. arghlp[i] = "Numeric file descriptor of open TCP connection";
  2018. break;
  2019. #endif /* TCPSOCKET */
  2020. case 'G':
  2021. opthlp[i] = "GET from server, send to standard output";
  2022. arghlp[i] = "Remote file specification";
  2023. optact[i] = 1;
  2024. break;
  2025. case 'H':
  2026. opthlp[i] = "Suppress program startup Herald and greeting";
  2027. arghlp[i] = NULL;
  2028. break;
  2029. case 'I':
  2030. opthlp[i] = "Connection is reliable, streaming is allowed";
  2031. arghlp[i] = NULL;
  2032. break;
  2033. #ifdef TCPSOCKET
  2034. case 'J':
  2035. opthlp[i] = "'Be like Telnet'";
  2036. arghlp[i] = "IP hostname/address optionally followed by service";
  2037. break;
  2038. #endif /* TCPSOCKET */
  2039. case 'L':
  2040. opthlp[i] = "Recursive directory descent for files in -s option";
  2041. arghlp[i] = NULL;
  2042. break;
  2043. case 'M':
  2044. opthlp[i] = "My user name (for use with Telnet, Rlogin, etc)";
  2045. arghlp[i] = "Username string";
  2046. break;
  2047. #ifdef NETBIOS
  2048. case 'N':
  2049. opthlp[i] = "NETBIOS adapter number";
  2050. arghlp[i] = "Number";
  2051. break;
  2052. #endif /* NETBIOS */
  2053. case 'O': /* Be a server for One command only */
  2054. opthlp[i] = "Be a server for One command only";
  2055. arghlp[i] = NULL;
  2056. optact[i] = 1;
  2057. break;
  2058. case 'P':
  2059. opthlp[i] = "Don't convert file (Path) names";
  2060. arghlp[i] = NULL;
  2061. break;
  2062. case 'Q':
  2063. opthlp[i] = "Quick (FAST) Kermit protocol settings";
  2064. arghlp[i] = NULL;
  2065. break;
  2066. case 'R': /* Remote-Only */
  2067. opthlp[i] = "Remote-only (makes IF REMOTE true)";
  2068. arghlp[i] = NULL;
  2069. break;
  2070. case 'S': /* "Stay" - enter interactive */
  2071. opthlp[i] = "Stay (enter command parser after action options)";
  2072. arghlp[i] = NULL;
  2073. break;
  2074. case 'T': /* Text file transfer mode */
  2075. opthlp[i] = "Transfer files in Text mode";
  2076. arghlp[i] = NULL;
  2077. break;
  2078. #ifdef ANYX25
  2079. case 'U': /* X.25 call user data */
  2080. opthlp[i] = "X.25 call User data";
  2081. arghlp[i] = "Call-user-data string";
  2082. break;
  2083. #endif /* ANYX25 */
  2084. case 'V': /* No automatic filetype switching */
  2085. opthlp[i] = "Disable automatic per-file text/binary switching";
  2086. arghlp[i] = NULL;
  2087. break;
  2088. #ifdef COMMENT
  2089. #ifdef OS2
  2090. case 'W': /* Win32 Window Handle */
  2091. opthlp[i] = "";
  2092. arghlp[i] = NULL;
  2093. break;
  2094. #endif /* OS2 */
  2095. #endif /* COMMENT */
  2096. #ifdef ANYX25
  2097. case 'X': /* SET HOST to X.25 address */
  2098. opthlp[i] = "Make an X.25 connection";
  2099. arghlp[i] = "X.25 or X.121 address";
  2100. break;
  2101. #endif /* ANYX25 */
  2102. case 'Y': /* No initialization file */
  2103. opthlp[i] = "Skip initialization file";
  2104. arghlp[i] = NULL;
  2105. break;
  2106. #ifdef ANYX25
  2107. case 'Z': /* SET HOST to X.25 file descriptor */
  2108. opthlp[i] = "Make an X.25 connection";
  2109. arghlp[i] = "Numeric file descriptor of open X.25 connection";
  2110. break;
  2111. #endif /* ANYX25 */
  2112. case 'a': /* as-name */
  2113. opthlp[i] = "As-name for file(s) in -s, -r, or -g";
  2114. arghlp[i] = "As-name string (alternative filename)";
  2115. break;
  2116. case 'b': /* Set bits-per-second for serial */
  2117. opthlp[i] = "Speed for serial device";
  2118. arghlp[i] = "Numeric Bits per second";
  2119. break;
  2120. case 'c': /* Connect before */
  2121. optact[i] = 1;
  2122. opthlp[i] = "CONNECT before transferring files";
  2123. arghlp[i] = NULL;
  2124. break;
  2125. case 'd': /* DEBUG */
  2126. opthlp[i] = "Create debug.log file (a second -d adds timestamps)";
  2127. arghlp[i] = NULL;
  2128. break;
  2129. case 'e': /* Extended packet length */
  2130. opthlp[i] = "Maximum length for incoming file-transfer packets";
  2131. arghlp[i] = "Length in bytes";
  2132. break;
  2133. case 'f': /* finish */
  2134. optact[i] = 1;
  2135. opthlp[i] = "Send Finish command to a Kermit server";
  2136. arghlp[i] = NULL;
  2137. break;
  2138. case 'g': /* get */
  2139. optact[i] = 1;
  2140. opthlp[i] = "GET file(s) from a Kermit server";
  2141. arghlp[i] = "Remote file specification";
  2142. break;
  2143. case 'h': /* help */
  2144. optact[i] = 1;
  2145. #ifdef OS2ORUNIX
  2146. opthlp[i] =
  2147. "Print this message (pipe thru 'more' to prevent scrolling)";
  2148. #else
  2149. "Print this message";
  2150. #endif /* OS2ORUNIX */
  2151. arghlp[i] = NULL;
  2152. break;
  2153. case 'i': /* Treat files as binary */
  2154. opthlp[i] ="Transfer files in binary mode";
  2155. arghlp[i] = NULL;
  2156. break;
  2157. #ifdef TCPSOCKET
  2158. case 'j': /* SET HOST (TCP/IP socket) */
  2159. opthlp[i] = "Make a TCP connection";
  2160. arghlp[i] =
  2161. "TCP host name/address and optional service name or number";
  2162. break;
  2163. #endif /* TCPSOCKET */
  2164. case 'k': /* receive to stdout */
  2165. optact[i] = 1;
  2166. opthlp[i] = "RECEIVE file(s) to standard output";
  2167. arghlp[i] = NULL;
  2168. break;
  2169. case 'l': /* SET LINE */
  2170. opthlp[i] = "Make connection on serial communications device";
  2171. arghlp[i] = "Serial device name";
  2172. break;
  2173. case 'm': /* Modem type */
  2174. opthlp[i] = "Modem type for use with -l device";
  2175. arghlp[i] = "Modem name as in SET MODEM TYPE command";
  2176. break;
  2177. case 'n': /* connect after */
  2178. optact[i] = 1;
  2179. opthlp[i] = "CONNECT after transferring files";
  2180. arghlp[i] = NULL;
  2181. break;
  2182. #ifdef ANYX25
  2183. case 'o': /* X.25 closed user group */
  2184. opthlp[i] = "X.25 closed user group";
  2185. arghlp[i] = "User group string";
  2186. break;
  2187. #endif /* ANYX25 */
  2188. case 'p': /* SET PARITY */
  2189. opthlp[i] = "Parity";
  2190. arghlp[i] = "One of the following: even, odd, mark, none, space";
  2191. break;
  2192. case 'q': /* Quiet */
  2193. opthlp[i] = "Quiet (suppress most messages)";
  2194. arghlp[i] = NULL;
  2195. break;
  2196. case 'r': /* receive */
  2197. optact[i] = 1;
  2198. opthlp[i] = "RECEIVE file(s)";
  2199. arghlp[i] = NULL;
  2200. break;
  2201. case 's': /* send */
  2202. optact[i] = 1;
  2203. opthlp[i] = "SEND file(s)";
  2204. arghlp[i] = "One or more file specifications";
  2205. break;
  2206. case 't': /* Line turnaround handshake */
  2207. opthlp[i] = "XON Turnaround character for half-duplex connections";
  2208. arghlp[i] = NULL;
  2209. break;
  2210. #ifdef ANYX25
  2211. case 'u': /* X.25 reverse charge call */
  2212. opthlp[i] = "X.25 reverse charge call";
  2213. arghlp[i] = NULL;
  2214. break;
  2215. #endif /* ANYX25 */
  2216. case 'v': /* Vindow size */
  2217. opthlp[i] = "Window size";
  2218. arghlp[i] = "Number, 1 to 32";
  2219. break;
  2220. case 'w': /* Writeover */
  2221. opthlp[i] = "Incoming files Write over existing files";
  2222. arghlp[i] = NULL;
  2223. break;
  2224. case 'x': /* Server */
  2225. optact[i] = 1;
  2226. opthlp[i] = "Be a Kermit SERVER";
  2227. arghlp[i] = NULL;
  2228. break;
  2229. case 'y': /* Alternate init-file name */
  2230. opthlp[i] = "Alternative initialization file";
  2231. arghlp[i] = "File specification";
  2232. break;
  2233. case 'z': /* Not background */
  2234. opthlp[i] = "Force foreground behavior";
  2235. arghlp[i] = NULL;
  2236. break;
  2237. default:
  2238. opthlp[i] = NULL;
  2239. arghlp[i] = NULL;
  2240. }
  2241. }
  2242. inixopthlp();
  2243. }
  2244. int
  2245. doxarg(s,pre) char ** s; int pre; {
  2246. #ifdef IKSD
  2247. #ifdef CK_LOGIN
  2248. extern int ckxsyslog, ckxwtmp, ckxanon;
  2249. #ifdef UNIX
  2250. extern int ckxpriv;
  2251. #endif /* UNIX */
  2252. #ifdef CK_PERMS
  2253. extern int ckxperms;
  2254. #endif /* CK_PERMS */
  2255. extern char * anonfile, * userfile, * anonroot;
  2256. #endif /* CK_LOGIN */
  2257. #ifdef CKWTMP
  2258. extern char * wtmpfile;
  2259. #endif /* CKWTMP */
  2260. #endif /* IKSD */
  2261. extern int srvcdmsg;
  2262. extern char * cdmsgfile[], * cdmsgstr;
  2263. char tmpbuf[CKMAXPATH+1];
  2264. int i, x, y, z, havearg = 0;
  2265. char buf[XARGBUFL], c, * p;
  2266. if (nxargs < 1)
  2267. return(-1);
  2268. c = *(*s + 1); /* Hyphen or Plus sign */
  2269. p = *s + 2;
  2270. for (i = 0; *p && i < XARGBUFL; i++) {
  2271. buf[i] = *p++;
  2272. if (buf[i] == '=' || buf[i] == ':') {
  2273. havearg = 1;
  2274. buf[i] = NUL;
  2275. break;
  2276. } else if (buf[i] < ' ') {
  2277. buf[i] = NUL;
  2278. break;
  2279. }
  2280. }
  2281. if (i > XARGBUFL - 1)
  2282. return(-1);
  2283. buf[i] = NUL;
  2284. x = lookup(xargtab,buf,nxargs,&z); /* Lookup the option keyword */
  2285. if (x < 0) /* On any kind of error */
  2286. return(-1); /* fail. */
  2287. /* Handle prescan versus post-initialization file */
  2288. if (((xargtab[z].flgs & CM_PRE) || (c == '+')) && !pre)
  2289. return(0);
  2290. else if (pre && !(xargtab[z].flgs & CM_PRE) && (c != '+'))
  2291. return(0);
  2292. /* Ensure that argument is given if and only if required */
  2293. p = havearg ? *s + i + 3 : NULL;
  2294. if ((xargtab[z].flgs & CM_ARG) && !havearg)
  2295. return(-1);
  2296. else if ((!(xargtab[z].flgs & CM_ARG)) && havearg)
  2297. return(-1);
  2298. switch (x) { /* OK to process this option... */
  2299. #ifdef CKSYSLOG
  2300. case XA_SYSL: /* IKS: Syslog level */
  2301. y = 0;
  2302. if (isdigit(*p)) {
  2303. while (*p) {
  2304. if (*p < '0' || *p > '9')
  2305. return(-1);
  2306. y = y * 10 + (*p++ - '0');
  2307. }
  2308. } else {
  2309. y = lookup(oktab,p,noktab,&z);
  2310. if (y > 0) y = SYSLG_DF; /* Yes = default logging level */
  2311. }
  2312. #ifndef SYSLOGLEVEL
  2313. /* If specified on cc command line, user can't change it. */
  2314. if (!inserver) /* Don't allow voluminous syslogging */
  2315. if (y > SYSLG_FA) /* by ordinary users. */
  2316. y = SYSLG_FA;
  2317. #endif /* SYSLOGLEVEL */
  2318. if (y < 0) return(-1);
  2319. #ifdef DEBUG
  2320. if (y >= SYSLG_DB)
  2321. if (!deblog)
  2322. deblog = debopn("debug.log",0);
  2323. #endif /* DEBUG */
  2324. #ifdef SYSLOGLEVEL
  2325. /* If specified on cc command line, user can't change it. */
  2326. y = SYSLOGLEVEL;
  2327. #endif /* SYSLOGLEVEL */
  2328. ckxsyslog = y;
  2329. /* printf("ckxsyslog=%d\n",ckxsyslog); */
  2330. break;
  2331. #endif /* CKSYSLOG */
  2332. #ifdef CK_LOGIN
  2333. #ifdef CKWTMP
  2334. case XA_WTMP: /* IKS: wtmp log */
  2335. y = lookup(oktab,p,noktab,&z);
  2336. if (y < 0) return(-1);
  2337. ckxwtmp = y;
  2338. /* printf("ckxwtmp=%d\n",ckxwtmp); */
  2339. break;
  2340. case XA_WTFI: /* IKS: wtmp logfile */
  2341. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2342. p = tmpbuf;
  2343. makestr(&wtmpfile,p);
  2344. /* printf("wtmpfile=%s\n",wtmpfile); */
  2345. break;
  2346. #endif /* CKWTMP */
  2347. case XA_ANON: /* IKS: Anonymous login allowed */
  2348. y = lookup(oktab,p,noktab,&z);
  2349. if (y < 0) return(-1);
  2350. ckxanon = y;
  2351. /* printf("ckxanon=%d\n",ckxanon); */
  2352. break;
  2353. #ifdef UNIX
  2354. case XA_PRIV: /* IKS: Priv'd login allowed */
  2355. y = lookup(oktab,p,noktab,&z);
  2356. if (y < 0) return(-1);
  2357. ckxpriv = y;
  2358. /* printf("ckxpriv=%d\n",ckxpriv); */
  2359. break;
  2360. #endif /* UNIX */
  2361. #ifdef CK_PERMS
  2362. case XA_PERM: /* IKS: Anonymous Upload Permissions */
  2363. y = 0;
  2364. while (*p) {
  2365. if (*p < '0' || *p > '7')
  2366. return(-1);
  2367. y = y * 8 + (*p++ - '0');
  2368. }
  2369. ckxperms = y;
  2370. /* printf("ckxperms=%04o\n",ckxperms); */
  2371. break;
  2372. #endif /* CK_PERMS */
  2373. case XA_ANFI: /* Anonymous init file */
  2374. if (!isabsolute(p))
  2375. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2376. p = tmpbuf;
  2377. makestr(&anonfile,p);
  2378. /* printf("anonfile=%s\n",anonfile); */
  2379. break;
  2380. case XA_USFI: /* IKS: Forbidden user file */
  2381. if (!isabsolute(p))
  2382. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2383. p = tmpbuf;
  2384. makestr(&userfile,p);
  2385. /* printf("userfile=%s\n",userfile); */
  2386. break;
  2387. case XA_ROOT: /* IKS: Anonymous root */
  2388. if (!isabsolute(p))
  2389. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2390. p = tmpbuf;
  2391. makestr(&anonroot,p);
  2392. /* printf("anonroot=%s\n",anonroot); */
  2393. break;
  2394. #endif /* CK_LOGIN */
  2395. case XA_CDFI: /* CD filename */
  2396. #ifdef COMMENT
  2397. /* Do NOT expand this one! */
  2398. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2399. p = tmpbuf;
  2400. #endif /* COMMENT */
  2401. makelist(p,cdmsgfile,16);
  2402. makestr(&cdmsgstr,p);
  2403. /* printf("cdmsgstr=%s\n",cdmsgstr); */
  2404. break;
  2405. case XA_CDMS: /* CD messages */
  2406. y = lookup(oktab,p,noktab,&z);
  2407. if (y < 0) return(-1);
  2408. srvcdmsg = y;
  2409. /* printf("srvcdmsg=%d\n",srvcdmsg); */
  2410. break;
  2411. #ifndef NOXFER
  2412. case XA_IKLG: /* Transfer log on/off */
  2413. y = lookup(oktab,p,noktab,&z);
  2414. if (y < 0) return(-1);
  2415. xferlog = y;
  2416. /* printf("xferlog=%d\n",xferlog); */
  2417. break;
  2418. case XA_IKFI: /* Transfer log file */
  2419. if (!isabsolute(p))
  2420. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2421. p = tmpbuf;
  2422. makestr(&xferfile,p);
  2423. xferlog = 1;
  2424. /* printf("xferfile=%s\n",xferfile); */
  2425. break;
  2426. case XA_BAFI: /* IKS: banner (greeting) file */
  2427. if (!isabsolute(p))
  2428. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2429. p = tmpbuf;
  2430. makestr(&bannerfile,p);
  2431. /* printf("bannerfile=%s\n",bannerfile); */
  2432. break;
  2433. #endif /* NOXFER */
  2434. #ifndef NOHELP
  2435. case XA_HELP: /* Help */
  2436. /* printf("help\n"); */
  2437. for (i = 0; i <= XA_MAX; i++)
  2438. if (xopthlp[i])
  2439. printf("%s\n %s\n\n",xopthlp[i],xarghlp[i]);
  2440. if (stayflg || what == W_COMMAND)
  2441. break;
  2442. else
  2443. doexit(GOOD_EXIT,-1);
  2444. #endif /* NOHELP */
  2445. #ifndef NOHELP
  2446. case XA_HEFI: /* IKS: custom help file */
  2447. if (!isabsolute(p))
  2448. if (zfnqfp(p,CKMAXPATH,tmpbuf))
  2449. p = tmpbuf;
  2450. makestr(&helpfile,p);
  2451. /* printf("helpfile=%s\n",helpfile); */
  2452. break;
  2453. #endif /* NOHELP */
  2454. #ifdef CK_LOGIN
  2455. case XA_TIMO:
  2456. if (!rdigits(p))
  2457. return(-1);
  2458. logintimo = atoi(p);
  2459. /* printf("logintimo=%d\n",p); */
  2460. break;
  2461. #endif /* CK_LOGIN */
  2462. case XA_NOIN: /* No interrupts */
  2463. #ifndef NOICP
  2464. cmdint = 0;
  2465. #endif /* NOICP */
  2466. xsuspend = 0;
  2467. break;
  2468. #ifdef UNIX
  2469. case XA_UNBUF: /* Unbuffered console i/o*/
  2470. break; /* This one is handled in ckcmai.c */
  2471. #endif /* UNIX */
  2472. #ifdef IKSDB
  2473. case XA_DBFI: {
  2474. extern char * dbdir, * dbfile;
  2475. extern int dbenabled;
  2476. struct zfnfp * zz;
  2477. if ((zz = zfnqfp(p,CKMAXPATH,tmpbuf))) {
  2478. char *s, *s2 = NULL;
  2479. makestr(&dbdir,zz->fpath);
  2480. makestr(&dbfile,zz->fpath);
  2481. for (s = dbdir; *s; s++) {
  2482. if (ISDIRSEP(*s))
  2483. s2 = s+1;
  2484. }
  2485. if (s2) *s2 = NUL;
  2486. debug(F110,"XA_DBFI dbdir",dbdir,0);
  2487. debug(F110,"XA_DBFI dbfile",dbfile,0);
  2488. dbenabled = 1;
  2489. }
  2490. break;
  2491. }
  2492. case XA_DBAS: {
  2493. extern int dbenabled;
  2494. y = lookup(oktab,p,noktab,&z);
  2495. if (y < 0) return(-1);
  2496. dbenabled = y;
  2497. break;
  2498. }
  2499. #endif /* IKSDB */
  2500. case XA_VERS: {
  2501. extern char * ck_s_ver, * ck_s_xver;
  2502. printf("%s",ck_s_ver);
  2503. if (*ck_s_xver)
  2504. printf(" [%s]\n",ck_s_xver);
  2505. printf("\n");
  2506. if (stayflg || what == W_COMMAND)
  2507. break;
  2508. else
  2509. doexit(GOOD_EXIT,-1);
  2510. }
  2511. #ifndef NOXFER
  2512. #ifdef CK_PERMS
  2513. case XA_NPRM: {
  2514. extern int atlpri, atlpro, atgpri, atgpro;
  2515. atlpri = 0;
  2516. atlpro = 0;
  2517. atgpri = 0;
  2518. atgpro = 0;
  2519. break;
  2520. }
  2521. #endif /* CK_PERMS */
  2522. #endif /* NOXFER */
  2523. #ifdef KUI
  2524. case XA_SCALE:
  2525. kui_init.resizeMode = 1;
  2526. break;
  2527. case XA_CHGD:
  2528. kui_init.resizeMode = 2;
  2529. break;
  2530. case XA_WMAX:
  2531. kui_init.nCmdShow = SW_MAXIMIZE;
  2532. break;
  2533. case XA_WMIN:
  2534. kui_init.nCmdShow = SW_MINIMIZE;
  2535. break;
  2536. case XA_XPOS:
  2537. if (!rdigits(p))
  2538. return(-1);
  2539. kui_init.pos_init++;
  2540. kui_init.pos_x = atoi(p);
  2541. break;
  2542. case XA_YPOS:
  2543. if (!rdigits(p))
  2544. return(-1);
  2545. kui_init.pos_init++;
  2546. kui_init.pos_y = atoi(p);
  2547. break;
  2548. case XA_FNAM: {
  2549. extern struct _kui_init kui_init;
  2550. extern struct keytab * term_font;
  2551. extern struct keytab * _term_font;
  2552. extern int tt_font, ntermfont;
  2553. int x, z;
  2554. if (ntermfont == 0)
  2555. BuildFontTable(&term_font, &_term_font, &ntermfont);
  2556. if (!(term_font && _term_font && ntermfont > 0)) {
  2557. printf("?Unable to construct Font Facename Table\n");
  2558. return(0);
  2559. }
  2560. x = lookup(term_font,p,ntermfont,&z);
  2561. if (x < 0) {
  2562. x = lookup(_term_font,p,ntermfont,&z);
  2563. if (x < 0) {
  2564. printf("?Invalid Font Facename: %s\n",p);
  2565. return(0);
  2566. }
  2567. }
  2568. tt_font = x;
  2569. kui_init.face_init++;
  2570. makestr(&kui_init.facename,term_font[z].kwd);
  2571. break;
  2572. }
  2573. case XA_FSIZ: {
  2574. extern struct _kui_init kui_init;
  2575. extern int tt_font_size;
  2576. char * q;
  2577. int halfpoint = 0;
  2578. kui_init.font_init++;
  2579. for ( q=p ; *q ; q++ ) {
  2580. if ( *q == '.') {
  2581. *q++ = '\0';
  2582. if (!rdigits(q))
  2583. return(-1);
  2584. if (!*q || atoi(q) == 0)
  2585. break; /* no halfpoint */
  2586. halfpoint = 1;
  2587. if (atoi(q) != 5)
  2588. printf("? Font sizes are treated in half-point increments\n");
  2589. break;
  2590. }
  2591. }
  2592. if (!rdigits(p))
  2593. return(-1);
  2594. tt_font_size = kui_init.font_size = 2 * atoi(p) + halfpoint;
  2595. break;
  2596. }
  2597. case XA_NOMN:
  2598. kui_init.nomenubar = 1;
  2599. break;
  2600. case XA_NOTB:
  2601. kui_init.notoolbar = 1;
  2602. break;
  2603. case XA_NOSB:
  2604. kui_init.nostatusbar = 1;
  2605. break;
  2606. case XA_NOBAR:
  2607. kui_init.nomenubar = 1;
  2608. kui_init.notoolbar = 1;
  2609. kui_init.nostatusbar = 1;
  2610. break;
  2611. #endif /* KUI */
  2612. #ifndef NOPUSH
  2613. case XA_NOPUSH:
  2614. nopush = 1;
  2615. break;
  2616. #endif /* NOPUSH */
  2617. #ifdef OS2
  2618. case XA_LOCK:
  2619. tt_scroll = 0;
  2620. tt_escape = 0;
  2621. #ifndef NOPUSH
  2622. nopush = 1;
  2623. #endif
  2624. #ifdef KUI
  2625. kui_init.nomenubar = 1;
  2626. kui_init.notoolbar = 1;
  2627. kui_init.nostatusbar = 1;
  2628. #endif
  2629. break;
  2630. #ifdef KUI
  2631. case XA_NOCLOSE:
  2632. kui_init.noclose = 1;
  2633. break;
  2634. #endif /* KUI */
  2635. case XA_NOSCROLL:
  2636. tt_scroll = 0;
  2637. break;
  2638. case XA_NOESCAPE:
  2639. tt_escape = 0;
  2640. break;
  2641. #endif /* OS2 */
  2642. #ifndef NOLOCAL
  2643. case XA_TERM: { /* Terminal type */
  2644. extern struct keytab ttyptab[];
  2645. extern int nttyp;
  2646. #ifdef TNCODE
  2647. extern char * tn_term;
  2648. #endif /* TNCODE */
  2649. #ifdef OS2
  2650. int x, z;
  2651. extern int tt_type, tt_type_mode;
  2652. x = lookup(ttyptab,p,nttyp,&z);
  2653. if (x < 0)
  2654. return(-1);
  2655. tt_type_mode = tt_type = x;
  2656. #endif /* OS2 */
  2657. #ifdef TNCODE
  2658. makestr(&tn_term,p);
  2659. #endif /* TNCODE */
  2660. break;
  2661. }
  2662. case XA_CSET: { /* Remote Character Set */
  2663. #ifndef NOCSETS
  2664. #ifdef CKOUNI
  2665. extern struct keytab txrtab[];
  2666. extern int ntxrtab;
  2667. x = lookup(txrtab,p,ntxrtab,&z);
  2668. #else /* CKOUNI */
  2669. extern struct keytab ttcstab[];
  2670. extern int ntermc;
  2671. x = lookup(ttcstab,p,ntermc,&z);
  2672. #endif /* CKOUNI */
  2673. if (x < 0)
  2674. return(-1);
  2675. setremcharset(z,4 /* TT_GR_ALL (in ckuus7.c) */);
  2676. #else /* NOCSETS */
  2677. return(-1);
  2678. #endif /* NOCSETS */
  2679. break;
  2680. }
  2681. case XA_ROWS: { /* Screen rows (height) */
  2682. #ifdef OS2
  2683. extern int row_init;
  2684. #else /* OS2 */
  2685. extern int tt_rows;
  2686. #endif /* OS2 */
  2687. if (!rdigits(p))
  2688. return(-1);
  2689. #ifdef OS2
  2690. if (!os2_settermheight(atoi(p)))
  2691. return(-1);
  2692. row_init++;
  2693. #else /* Not OS/2 */
  2694. tt_rows = atoi(p);
  2695. #endif /* OS2 */
  2696. break;
  2697. }
  2698. case XA_COLS: { /* Screen columns (width) */
  2699. #ifdef OS2
  2700. extern int col_init;
  2701. #else /* OS2 */
  2702. extern int tt_cols;
  2703. #endif /* OS2 */
  2704. if (!rdigits(p))
  2705. return(-1);
  2706. #ifdef OS2
  2707. if (!os2_settermwidth(atoi(p)))
  2708. return(-1);
  2709. col_init++;
  2710. #else /* Not OS/2 */
  2711. tt_cols = atoi(p);
  2712. #endif /* OS2 */
  2713. break;
  2714. }
  2715. #ifdef OS2
  2716. case XA_TITL: {
  2717. extern char usertitle[];
  2718. ckstrncpy(usertitle,p,64);
  2719. os2settitle("",1);
  2720. break;
  2721. }
  2722. #endif /* OS2 */
  2723. #ifdef COMMENT /* TO BE FILLED IN ... */
  2724. case XA_TEL: /* Make a Telnet connection */
  2725. case XA_FTP: /* Make an FTP connection */
  2726. case XA_SSH: /* Make an SSH connection */
  2727. #endif /* COMMENT */
  2728. #ifndef NOSPL
  2729. case XA_USER: /* Username for login */
  2730. #ifdef IKSD
  2731. if (!inserver)
  2732. #endif /* IKSD */
  2733. {
  2734. ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
  2735. haveftpuid = 1;
  2736. }
  2737. break;
  2738. #endif /* NOSPL */
  2739. #endif /* NOLOCAL */
  2740. case XA_NOLOCALE: { /* Don't do locale */
  2741. extern int nolocale;
  2742. nolocale = 1;
  2743. break;
  2744. }
  2745. default:
  2746. return(-1);
  2747. }
  2748. return(0);
  2749. }
  2750. #ifdef IKSD
  2751. #ifdef IKSDCONF
  2752. #define IKS_ANON 0
  2753. #define IKS_BAFI 1
  2754. #define IKS_CDFI 2
  2755. #define IKS_CDMS 3
  2756. #define IKS_HEFI 4
  2757. #define IKS_ANFI 5
  2758. #define IKS_USFI 6
  2759. #define IKS_IKLG 7
  2760. #define IKS_IKFI 8
  2761. #define IKS_DBAS 9
  2762. #define IKS_DBFI 10
  2763. #define IKS_PERM 11
  2764. #define IKS_PRIV 12
  2765. #define IKS_ROOT 13
  2766. #define IKS_TIMO 14
  2767. #define IKS_WTFI 15
  2768. #define IKS_WTMP 16
  2769. #define IKS_SRVR 17
  2770. #define IKS_NOIN 18
  2771. #define IKS_INIT 19
  2772. #define IKS_ANLG 20
  2773. #define IKS_ACCT 21
  2774. #define IKS_NTDOM 22
  2775. #define IKS_SYSL 23
  2776. #ifdef CK_LOGIN
  2777. static struct keytab iksantab[] = {
  2778. #ifdef OS2
  2779. { "account", IKS_ACCT, 0 },
  2780. #endif /* OS2 */
  2781. { "initfile", IKS_ANFI, 0 },
  2782. { "login", IKS_ANLG, 0 },
  2783. #ifdef UNIX
  2784. { "root", IKS_ROOT, 0 },
  2785. #else
  2786. #ifdef CKROOT
  2787. { "root", IKS_ROOT, 0 },
  2788. #endif /* CKROOT */
  2789. #endif /* UNIX */
  2790. { "", 0, 0 }
  2791. };
  2792. static int niksantab = sizeof(iksantab) / sizeof(struct keytab) - 1;
  2793. #endif /* CK_LOGIN */
  2794. static struct keytab ikstab[] = {
  2795. #ifdef CK_LOGIN
  2796. { "anonymous", IKS_ANON, 0 },
  2797. #endif /* CK_LOGIN */
  2798. { "bannerfile", IKS_BAFI, 0 },
  2799. { "cdfile", IKS_CDFI, 0 },
  2800. { "cdmessage", IKS_CDMS, 0 },
  2801. { "cdmsg", IKS_CDMS, CM_INV },
  2802. #ifdef IKSDB
  2803. { "database", IKS_DBAS, 0 },
  2804. { "dbfile", IKS_DBFI, 0 },
  2805. #endif /* IKSDB */
  2806. #ifdef CK_LOGIN
  2807. #ifdef NT
  2808. { "default-domain", IKS_NTDOM, 0 },
  2809. #endif /* NT */
  2810. #endif /* CK_LOGIN */
  2811. #ifndef NOHELP
  2812. { "helpfile", IKS_HEFI, 0 },
  2813. #endif /* NOHELP */
  2814. { "initfile", IKS_INIT, 0 },
  2815. { "no-initfile", IKS_NOIN, 0 },
  2816. #ifdef CK_LOGIN
  2817. #ifdef CK_PERM
  2818. { "permissions", IKS_PERM, 0 },
  2819. { "perms", IKS_PERM, CM_INV },
  2820. #endif /* CK_PERM */
  2821. #ifdef UNIX
  2822. { "privid", IKS_PRIV, 0 },
  2823. #endif /* UNIX */
  2824. { "server-only", IKS_SRVR, 0 },
  2825. #ifdef CKSYSLOG
  2826. { "syslog", IKS_SYSL, 0 },
  2827. #endif /* CKSYSLOG */
  2828. { "timeout", IKS_TIMO, 0 },
  2829. { "userfile", IKS_USFI, 0 },
  2830. #ifdef CKWTMP
  2831. { "wtmpfile", IKS_WTFI, 0 },
  2832. { "wtmplog", IKS_WTMP, 0 },
  2833. #endif /* CKWTMP */
  2834. #endif /* CK_LOGIN */
  2835. { "xferfile", IKS_IKFI, 0 },
  2836. { "xferlog", IKS_IKLG, 0 }
  2837. };
  2838. static int nikstab = sizeof(ikstab) / sizeof(struct keytab);
  2839. #endif /* IKSDCONF */
  2840. #ifndef NOICP
  2841. int
  2842. setiks() { /* SET IKS */
  2843. #ifdef IKSDCONF
  2844. #ifdef CK_LOGIN
  2845. extern int ckxsyslog, ckxwtmp, ckxanon;
  2846. #ifdef UNIX
  2847. extern int ckxpriv;
  2848. #endif /* UNIX */
  2849. #ifdef CK_PERMS
  2850. extern int ckxperms;
  2851. #endif /* CK_PERMS */
  2852. extern char * anonfile, * userfile, * anonroot;
  2853. #ifdef OS2
  2854. extern char * anonacct;
  2855. #endif /* OS2 */
  2856. #ifdef NT
  2857. extern char * iks_domain;
  2858. #endif /* NT */
  2859. #endif /* CK_LOGIN */
  2860. #ifdef CKWTMP
  2861. extern char * wtmpfile;
  2862. #endif /* CKWTMP */
  2863. extern int srvcdmsg, success, iksdcf, rcflag, noinit, arg_x;
  2864. extern char * cdmsgfile[], * cdmsgstr, *kermrc;
  2865. extern xx_strp xxstring;
  2866. int x, y, z;
  2867. char *s;
  2868. char tmpbuf[CKMAXPATH+1];
  2869. if ((y = cmkey(ikstab,nikstab,"","",xxstring)) < 0)
  2870. return(y);
  2871. #ifdef CK_LOGIN
  2872. if (y == IKS_ANON) {
  2873. if ((y = cmkey(iksantab,niksantab,"","",xxstring)) < 0)
  2874. return(y);
  2875. }
  2876. #endif /* CK_LOGIN */
  2877. switch (y) {
  2878. #ifdef CKSYSLOG
  2879. case IKS_SYSL: /* IKS: Syslog level */
  2880. if ((z = cmkey(oktab,noktab,"","",xxstring)) < 0)
  2881. return(z);
  2882. if ((x = cmcfm()) < 0) return(x);
  2883. if (iksdcf) return(success = 0);
  2884. #ifndef SYSLOGLEVEL
  2885. /* If specified on cc command line, user can't change it. */
  2886. if (!inserver) /* Don't allow voluminous syslogging */
  2887. if (y > SYSLG_FA) /* by ordinary users. */
  2888. y = SYSLG_FA;
  2889. #endif /* SYSLOGLEVEL */
  2890. if (y < 0) return(-1);
  2891. #ifdef DEBUG
  2892. if (y >= SYSLG_DB)
  2893. if (!deblog)
  2894. deblog = debopn("debug.log",0);
  2895. #endif /* DEBUG */
  2896. #ifdef SYSLOGLEVEL
  2897. /* If specified on cc command line, user can't change it. */
  2898. y = SYSLOGLEVEL;
  2899. #endif /* SYSLOGLEVEL */
  2900. ckxsyslog = y;
  2901. /* printf("ckxsyslog=%d\n",ckxsyslog); */
  2902. break;
  2903. #endif /* CKSYSLOG */
  2904. #ifdef CK_LOGIN
  2905. #ifdef NT
  2906. case IKS_NTDOM:
  2907. if ((z = cmtxt(
  2908. "DOMAIN to be used for user authentication when none is specified",
  2909. "", &s,xxstring)) < 0)
  2910. return(z);
  2911. if (iksdcf) return(success = 0);
  2912. if (!*s) s= NULL;
  2913. makestr(&iks_domain,s);
  2914. break;
  2915. #endif /* NT */
  2916. #ifdef OS2
  2917. case IKS_ACCT:
  2918. if ((z = cmtxt("Name of local account to use for anonymous logins",
  2919. "GUEST", &s,xxstring)) < 0)
  2920. return(z);
  2921. if (iksdcf) return(success = 0);
  2922. if (*s) {
  2923. makestr(&anonacct,s);
  2924. } else if ( anonacct ) {
  2925. free(anonacct);
  2926. anonacct = NULL;
  2927. }
  2928. break;
  2929. #endif /* OS2 */
  2930. case IKS_ANLG:
  2931. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  2932. return(z);
  2933. if ((x = cmcfm()) < 0) return(x);
  2934. if (iksdcf) return(success = 0);
  2935. ckxanon = z;
  2936. #ifdef OS2
  2937. if (ckxanon && !anonacct)
  2938. makestr(&anonacct,"GUEST");
  2939. #endif /* OS2 */
  2940. break;
  2941. #endif /* CK_LOGIN */
  2942. case IKS_BAFI:
  2943. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  2944. return(z);
  2945. if (x) {
  2946. printf("?Wildcards not allowed\n");
  2947. return(-9);
  2948. }
  2949. debug(F110,"bannerfile before zfnqfp()",s,0);
  2950. if (zfnqfp(s,CKMAXPATH,tmpbuf)) {
  2951. debug(F110,"bannerfile after zfnqfp()",tmpbuf,0);
  2952. s = tmpbuf;
  2953. }
  2954. if ((x = cmcfm()) < 0) return(x);
  2955. if (iksdcf) return(success = 0);
  2956. if (*s)
  2957. makestr(&bannerfile,s);
  2958. break;
  2959. case IKS_CDFI:
  2960. if ((z = cmtxt("list of cd message file names","READ.ME",
  2961. &s,xxstring)) < 0)
  2962. return(z);
  2963. if (iksdcf) return(success = 0);
  2964. if (*s) {
  2965. makelist(s,cdmsgfile,16);
  2966. makestr(&cdmsgstr,s);
  2967. }
  2968. break;
  2969. case IKS_CDMS:
  2970. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  2971. return(z);
  2972. if ((x = cmcfm()) < 0) return(x);
  2973. if (iksdcf) return(success = 0);
  2974. srvcdmsg = z;
  2975. break;
  2976. case IKS_HEFI:
  2977. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  2978. return(z);
  2979. if (x) {
  2980. printf("?Wildcards not allowed\n");
  2981. return(-9);
  2982. }
  2983. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  2984. s = tmpbuf;
  2985. if ((x = cmcfm()) < 0) return(x);
  2986. if (iksdcf) return(success = 0);
  2987. if (*s)
  2988. makestr(&helpfile,s);
  2989. break;
  2990. case IKS_ANFI:
  2991. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  2992. return(z);
  2993. if (x) {
  2994. printf("?Wildcards not allowed\n");
  2995. return(-9);
  2996. }
  2997. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  2998. s = tmpbuf;
  2999. if ((x = cmcfm()) < 0) return(x);
  3000. if (iksdcf) return(success = 0);
  3001. if (*s)
  3002. makestr(&anonfile,s);
  3003. break;
  3004. case IKS_USFI:
  3005. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  3006. return(z);
  3007. if (x) {
  3008. printf("?Wildcards not allowed\n");
  3009. return(-9);
  3010. }
  3011. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  3012. s = tmpbuf;
  3013. if ((x = cmcfm()) < 0) return(x);
  3014. if (iksdcf) return(success = 0);
  3015. if (*s)
  3016. makestr(&userfile,s);
  3017. break;
  3018. case IKS_IKFI:
  3019. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  3020. return(z);
  3021. if (x) {
  3022. printf("?Wildcards not allowed\n");
  3023. return(-9);
  3024. }
  3025. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  3026. s = tmpbuf;
  3027. if ((x = cmcfm()) < 0) return(x);
  3028. if (iksdcf) return(success = 0);
  3029. if (*s) {
  3030. makestr(&xferfile,s);
  3031. xferlog = 1;
  3032. }
  3033. break;
  3034. case IKS_IKLG:
  3035. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3036. return(z);
  3037. if ((x = cmcfm()) < 0) return(x);
  3038. if (iksdcf) return(success = 0);
  3039. xferlog = z;
  3040. break;
  3041. #ifdef CK_LOGIN
  3042. #ifdef CK_PERM
  3043. case IKS_PERM:
  3044. if ((z = cmtxt("Octal file permssion code","000",
  3045. &s,xxstring)) < 0)
  3046. return(z);
  3047. if (z < 0) return(z);
  3048. if (iksdcf) return(success = 0);
  3049. y = 0;
  3050. while (*s) {
  3051. if (*s < '0' || *s > '7')
  3052. return(-9);
  3053. y = y * 8 + (*s++ - '0');
  3054. }
  3055. ckxperms = y;
  3056. break;
  3057. #endif /* CK_PERM */
  3058. #ifdef UNIX
  3059. case IKS_PRIV: /* IKS: Priv'd login allowed */
  3060. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3061. return(z);
  3062. if ((x = cmcfm()) < 0) return(x);
  3063. if (iksdcf) return(success = 0);
  3064. ckxpriv = z;
  3065. break;
  3066. #endif /* UNIX */
  3067. case IKS_ROOT: /* IKS: Anonymous root */
  3068. if ((z = cmdir("Name of disk and/or directory","",&s,
  3069. xxstring)) < 0 ) {
  3070. if (z != -3)
  3071. return(z);
  3072. }
  3073. if (*s) {
  3074. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  3075. s = tmpbuf;
  3076. } else
  3077. s = "";
  3078. if ((x = cmcfm()) < 0) return(x);
  3079. if (iksdcf) return(success = 0);
  3080. if (*s)
  3081. makestr(&anonroot,s);
  3082. /* printf("anonroot=%s\n",anonroot); */
  3083. break;
  3084. case IKS_TIMO:
  3085. z = cmnum("login timeout, seconds","0",10,&x,xxstring);
  3086. if (z < 0) return(z);
  3087. if (x < 0 || x > 7200) {
  3088. printf("?Value must be between 0 and 7200\r\n");
  3089. return(-9);
  3090. }
  3091. if ((z = cmcfm()) < 0) return(z);
  3092. if (iksdcf) return(success = 0);
  3093. logintimo = x;
  3094. break;
  3095. #ifdef CKWTMP
  3096. case IKS_WTMP: /* IKS: wtmp log */
  3097. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3098. return(z);
  3099. if ((x = cmcfm()) < 0) return(x);
  3100. if (iksdcf) return(success = 0);
  3101. ckxwtmp = z;
  3102. break;
  3103. case IKS_WTFI: /* IKS: wtmp logfile */
  3104. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  3105. return(z);
  3106. if (x) {
  3107. printf("?Wildcards not allowed\n");
  3108. return(-9);
  3109. }
  3110. if (zfnqfp(s,CKMAXPATH,tmpbuf))
  3111. s = tmpbuf;
  3112. if ((x = cmcfm()) < 0) return(x);
  3113. if (iksdcf) return(success = 0);
  3114. if (*s)
  3115. makestr(&wtmpfile,s);
  3116. break;
  3117. #endif /* CKWTMP */
  3118. #endif /* CK_LOGIN */
  3119. #ifdef IKSDB
  3120. case IKS_DBFI: {
  3121. extern char * dbdir, * dbfile;
  3122. extern int dbenabled;
  3123. struct zfnfp * zz;
  3124. if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
  3125. return(z);
  3126. if (x) {
  3127. printf("?Wildcards not allowed\n");
  3128. return(-9);
  3129. }
  3130. zz = zfnqfp(s,CKMAXPATH,tmpbuf);
  3131. if ((x = cmcfm()) < 0) return(x);
  3132. if (iksdcf) return(success = 0);
  3133. if (zz) {
  3134. makestr(&dbdir,zz->fpath);
  3135. makestr(&dbfile,(char *)tmpbuf);
  3136. dbenabled = 1;
  3137. } else
  3138. return(success = 0);
  3139. break;
  3140. }
  3141. case IKS_DBAS: {
  3142. extern int dbenabled;
  3143. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3144. return(z);
  3145. if ((x = cmcfm()) < 0) return(x);
  3146. if (iksdcf) return(success = 0);
  3147. dbenabled = z;
  3148. break;
  3149. }
  3150. #endif /* IKSDB */
  3151. case IKS_INIT:
  3152. if ((z = cmtxt("Alternate init file specification","",
  3153. &s,xxstring)) < 0)
  3154. return(z);
  3155. if (z < 0) return(z);
  3156. if (iksdcf) return(success = 0);
  3157. ckstrncpy(kermrc,s,KERMRCL);
  3158. rcflag = 1; /* Flag that this has been done */
  3159. break;
  3160. case IKS_NOIN:
  3161. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3162. return(z);
  3163. if ((x = cmcfm()) < 0) return(x);
  3164. if (iksdcf) return(success = 0);
  3165. noinit = z;
  3166. break;
  3167. case IKS_SRVR:
  3168. if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
  3169. return(z);
  3170. if ((x = cmcfm()) < 0) return(x);
  3171. if (iksdcf) return(success = 0);
  3172. arg_x = z;
  3173. break;
  3174. default:
  3175. return(-9);
  3176. }
  3177. return(success = (inserver ? 1 : 0));
  3178. #else /* IKSDCONF */
  3179. if ((x = cmcfm()) < 0)
  3180. return(x);
  3181. return(success = 0);
  3182. #endif /* IKSDCONF */
  3183. }
  3184. #endif /* NOICP */
  3185. #endif /* IKSD */
  3186. /* D O A R G -- Do a command-line argument. */
  3187. int
  3188. #ifdef CK_ANSIC
  3189. doarg(char x)
  3190. #else
  3191. doarg(x) char x;
  3192. #endif /* CK_ANSIC */
  3193. /* doarg */ {
  3194. int i, n, y, z, xx; long zz; char *xp;
  3195. #ifdef NETCONN
  3196. extern char *line, *tmpbuf; /* Character buffers for anything */
  3197. #endif /* NETCONN */
  3198. #ifdef IKSD
  3199. /* Internet Kermit Server set some way besides -A... */
  3200. if (inserver)
  3201. dofast();
  3202. #endif /* IKSD */
  3203. xp = *xargv+1; /* Pointer for bundled args */
  3204. debug(F111,"doarg entry",xp,xargc);
  3205. while (x) {
  3206. debug(F000,"doarg arg","",x);
  3207. switch (x) { /* Big switch on arg */
  3208. #ifndef COMMENT
  3209. case '-': /* Extended commands... */
  3210. if (doxarg(xargv,0) < 0) {
  3211. XFATAL("Extended option error");
  3212. } /* Full thru... */
  3213. case '+': /* Extended command for prescan() */
  3214. return(0);
  3215. #else /* NOICP */
  3216. case '-':
  3217. case '+':
  3218. XFATAL("Extended options not configured");
  3219. #endif /* NOICP */
  3220. #ifndef NOSPL
  3221. case 'C': { /* Commands for parser */
  3222. char * s;
  3223. xargv++, xargc--;
  3224. if ((xargc < 1) || (**xargv == '-')) {
  3225. XFATAL("No commands given for -C");
  3226. }
  3227. s = *xargv; /* Get the argument (must be quoted) */
  3228. if (!*s) /* If empty quotes */
  3229. s = NULL; /* ignore this option */
  3230. if (s) {
  3231. makestr(&clcmds,s); /* Make pokeable copy */
  3232. s = clcmds; /* Change tabs to spaces */
  3233. while (*s) {
  3234. if (*s == '\t') *s = ' ';
  3235. s++;
  3236. }
  3237. }
  3238. break;
  3239. }
  3240. #endif /* NOSPL */
  3241. #ifndef NOXFER
  3242. case 'D': /* Delay */
  3243. if (*(xp+1)) {
  3244. XFATAL("invalid argument bundling");
  3245. }
  3246. xargv++, xargc--;
  3247. if ((xargc < 1) || (**xargv == '-')) {
  3248. XFATAL("missing delay value");
  3249. }
  3250. z = atoi(*xargv); /* Convert to number */
  3251. if (z > -1) /* If in range */
  3252. ckdelay = z; /* set it */
  3253. else {
  3254. XFATAL("bad delay value");
  3255. }
  3256. break;
  3257. #endif /* NOXFER */
  3258. case 'E': /* Exit on close */
  3259. #ifdef NETCONN
  3260. tn_exit = 1;
  3261. #endif /* NETCONN */
  3262. exitonclose = 1;
  3263. break;
  3264. #ifndef NOICP
  3265. case 'S': /* "Stay" - enter interactive */
  3266. stayflg = 1; /* command parser after executing */
  3267. xfinish = 0; /* command-line actions. */
  3268. break;
  3269. #endif /* NOICP */
  3270. case 'T': /* File transfer mode = text */
  3271. binary = XYFT_T;
  3272. xfermode = XMODE_M; /* Transfer mode manual */
  3273. filepeek = 0;
  3274. #ifdef PATTERNS
  3275. patterns = 0;
  3276. #endif /* PATTERNS */
  3277. break;
  3278. case '7':
  3279. break;
  3280. #ifdef IKSD
  3281. case 'A': { /* Internet server */
  3282. /* Already done in prescan() */
  3283. /* but implies 'x' && 'Q' */
  3284. #ifdef OS2
  3285. char * p;
  3286. if (*(xp+1)) {
  3287. XFATAL("invalid argument bundling");
  3288. }
  3289. #ifdef NT
  3290. /* Support for Pragma Systems Telnet/Terminal Servers */
  3291. p = getenv("PRAGMASYS_INETD_SOCK");
  3292. if (!(p && atoi(p) != 0)) {
  3293. xargv++, xargc--;
  3294. if (xargc < 1 || **xargv == '-') {
  3295. XFATAL("missing socket handle");
  3296. }
  3297. }
  3298. #else /* NT */
  3299. xargv++, xargc--;
  3300. if (xargc < 1 || **xargv == '-') {
  3301. XFATAL("missing socket handle");
  3302. }
  3303. #endif /* NT */
  3304. #endif /* OS2 */
  3305. #ifdef NOICP /* If no Interactive Command Parser */
  3306. action = 'x'; /* -A implies -x. */
  3307. #endif /* NOICP */
  3308. #ifndef NOXFER
  3309. dofast();
  3310. #endif /* NOXFER */
  3311. break;
  3312. }
  3313. #endif /* IKSD */
  3314. #ifndef NOXFER
  3315. case 'Q': /* Quick (i.e. FAST) */
  3316. dofast();
  3317. break;
  3318. #endif /* NOXFER */
  3319. case 'R': /* Remote-Only */
  3320. break; /* This is handled in prescan(). */
  3321. #ifndef NOSERVER
  3322. case 'x': /* server */
  3323. case 'O': /* (for One command only) */
  3324. if (action) {
  3325. XFATAL("conflicting actions");
  3326. }
  3327. if (x == 'O') justone = 1;
  3328. xfinish = 1;
  3329. action = 'x';
  3330. break;
  3331. #endif /* NOSERVER */
  3332. #ifndef NOXFER
  3333. case 'f': /* finish */
  3334. if (action) {
  3335. XFATAL("conflicting actions");
  3336. }
  3337. action = setgen('F',"","","");
  3338. break;
  3339. #endif /* NOXFER */
  3340. case 'r': { /* receive */
  3341. if (action) {
  3342. XFATAL("conflicting actions");
  3343. }
  3344. action = 'v';
  3345. break;
  3346. }
  3347. #ifndef NOXFER
  3348. case 'k': /* receive to stdout */
  3349. if (action) {
  3350. XFATAL("conflicting actions");
  3351. }
  3352. stdouf = 1;
  3353. action = 'v';
  3354. break;
  3355. case 's': { /* send */
  3356. int fil2snd, rc;
  3357. if (!recursive)
  3358. nolinks = 0; /* Follow links by default */
  3359. if (action) {
  3360. XFATAL("conflicting actions");
  3361. }
  3362. if (*(xp+1)) {
  3363. XFATAL("invalid argument bundling after -s");
  3364. }
  3365. nfils = 0; /* Initialize file counter */
  3366. fil2snd = 0; /* Assume nothing to send */
  3367. z = 0; /* Flag for stdin */
  3368. cmlist = xargv + 1; /* Remember this pointer */
  3369. while (++xargv, --xargc > 0) { /* Traverse the list */
  3370. #ifdef PIPESEND
  3371. if (usepipes && protocol == PROTO_K && **xargv == '!') {
  3372. cmarg = *xargv;
  3373. cmarg++;
  3374. debug(F110,"doarg pipesend",cmarg,0);
  3375. nfils = -1;
  3376. z = 1;
  3377. pipesend = 1;
  3378. } else
  3379. #endif /* PIPESEND */
  3380. if (**xargv == '-') { /* Check for sending stdin */
  3381. if (strcmp(*xargv,"-") != 0) /* next option? */
  3382. break;
  3383. z++; /* "-" alone means send from stdin. */
  3384. #ifdef RECURSIVE
  3385. } else if (!strcmp(*xargv,".")) {
  3386. fil2snd = 1;
  3387. nfils++;
  3388. recursive = 1;
  3389. nolinks = 2;
  3390. #endif /* RECURSIVE */
  3391. } else /* Check if file exists */
  3392. if ((rc = zchki(*xargv)) > -1 || (rc == -2)) {
  3393. if (rc != -2)
  3394. fil2snd = 1;
  3395. nfils++; /* Bump file counter */
  3396. } else if (iswild(*xargv) && nzxpand(*xargv,0) > 0) {
  3397. /* or contains wildcard characters matching real files */
  3398. fil2snd = 1;
  3399. nfils++;
  3400. } else {
  3401. if (!failmsg)
  3402. failmsg = (char *)malloc(2000);
  3403. if (failmsg) {
  3404. ckmakmsg(failmsg,2000,
  3405. #ifdef VMS
  3406. "%CKERMIT-E-SEARCHFAIL "
  3407. #else
  3408. "kermit -s "
  3409. #endif /* VMS */
  3410. ,
  3411. *xargv,
  3412. ": ",
  3413. ck_errstr()
  3414. );
  3415. }
  3416. }
  3417. }
  3418. xargc++, xargv--; /* Adjust argv/argc */
  3419. if (!fil2snd && z == 0) {
  3420. if (!failmsg) {
  3421. #ifdef VMS
  3422. failmsg = "%CKERMIT-E-SEARCHFAIL, no files for -s";
  3423. #else
  3424. failmsg = "No files for -s";
  3425. #endif /* VMS */
  3426. }
  3427. XFATAL(failmsg);
  3428. }
  3429. if (z > 1) {
  3430. XFATAL("kermit -s: too many -'s");
  3431. }
  3432. if (z == 1 && fil2snd) {
  3433. XFATAL("invalid mixture of filenames and '-' in -s");
  3434. }
  3435. debug(F101,"doarg s nfils","",nfils);
  3436. debug(F101,"doarg s z","",z);
  3437. if (nfils == 0) { /* no file parameters were specified */
  3438. if (is_a_tty(0)) { /* (used to be is_a_tty(1) - why?) */
  3439. XFATAL("sending from terminal not allowed");
  3440. } else stdinf = 1;
  3441. }
  3442. debug(F101,"doarg s stdinf","",stdinf);
  3443. debug(F111,"doarg",*xargv,nfils);
  3444. action = 's';
  3445. break;
  3446. }
  3447. case 'g': /* get */
  3448. case 'G': /* get to stdout */
  3449. if (action) {
  3450. XFATAL("conflicting actions");
  3451. }
  3452. if (*(xp+1)) {
  3453. XFATAL("invalid argument bundling after -g");
  3454. }
  3455. xargv++, xargc--;
  3456. if ((xargc == 0) || (**xargv == '-')) {
  3457. XFATAL("missing filename for -g");
  3458. }
  3459. if (x == 'G') stdouf = 1;
  3460. cmarg = *xargv;
  3461. action = 'r';
  3462. break;
  3463. #endif /* NOXFER */
  3464. #ifndef NOLOCAL
  3465. case 'c': /* connect before */
  3466. cflg = 1;
  3467. break;
  3468. case 'n': /* connect after */
  3469. cnflg = 1;
  3470. break;
  3471. #endif /* NOLOCAL */
  3472. case 'h': /* help */
  3473. usage();
  3474. #ifndef NOICP
  3475. if (stayflg || what == W_COMMAND)
  3476. break;
  3477. else
  3478. #endif /* NOICP */
  3479. doexit(GOOD_EXIT,-1);
  3480. #ifndef NOXFER
  3481. case 'a': /* "as" */
  3482. if (*(xp+1)) {
  3483. XFATAL("invalid argument bundling after -a");
  3484. }
  3485. xargv++, xargc--;
  3486. if ((xargc < 1) || (**xargv == '-')) {
  3487. XFATAL("missing name in -a");
  3488. }
  3489. cmarg2 = *xargv;
  3490. debug(F111,"doarg a",cmarg2,xargc);
  3491. break;
  3492. #endif /* NOXFER */
  3493. #ifndef NOICP
  3494. case 'Y': /* No initialization file */
  3495. noinit = 1;
  3496. break;
  3497. case 'y': /* Alternate init-file name */
  3498. noinit = 0;
  3499. if (*(xp+1)) {
  3500. XFATAL("invalid argument bundling after -y");
  3501. }
  3502. xargv++, xargc--;
  3503. if (xargc < 1) {
  3504. XFATAL("missing filename in -y");
  3505. }
  3506. /* strcpy(kermrc,*xargv); ... already done in prescan()... */
  3507. break;
  3508. #endif /* NOICP */
  3509. #ifndef NOXFER
  3510. case 'I': /* Assume we have an "Internet" */
  3511. reliable = 1; /* or other reliable connection */
  3512. xreliable = 1;
  3513. setreliable = 1;
  3514. /* I'm not so sure about this -- what about VMS? (next comment) */
  3515. clearrq = 1; /* therefore the channel is clear */
  3516. #ifndef VMS
  3517. /*
  3518. Since this can trigger full control-character unprefixing, we need to
  3519. ensure that our terminal or pty driver is not doing Xon/Xoff; otherwise
  3520. we can become deadlocked the first time we receive a file that contains
  3521. Xoff.
  3522. */
  3523. flow = FLO_NONE;
  3524. #endif /* VMS */
  3525. break;
  3526. #endif /* NOXFER */
  3527. #ifndef NOLOCAL
  3528. case 'l': /* SET LINE */
  3529. #ifdef NETCONN
  3530. #ifdef ANYX25
  3531. case 'X': /* SET HOST to X.25 address */
  3532. #ifdef SUNX25
  3533. case 'Z': /* SET HOST to X.25 file descriptor */
  3534. #endif /* SUNX25 */
  3535. #endif /* ANYX25 */
  3536. #ifdef TCPSOCKET
  3537. case 'J':
  3538. case 'j': /* SET HOST (TCP/IP socket) */
  3539. #endif /* TCPSOCKET */
  3540. #endif /* NETCONN */
  3541. #ifndef NOXFER
  3542. if (x == 'j' || x == 'J' || x == 'X' || x == 'Z') {
  3543. reliable = 1; /* or other reliable connection */
  3544. xreliable = 1;
  3545. setreliable = 1;
  3546. }
  3547. #endif /* NOXFER */
  3548. network = 0;
  3549. if (*(xp+1)) {
  3550. XFATAL("invalid argument bundling after -l or -j");
  3551. }
  3552. xargv++, xargc--;
  3553. if ((xargc < 1) || (**xargv == '-')) {
  3554. XFATAL("communication line device name missing");
  3555. }
  3556. #ifdef NETCONN
  3557. if (x == 'J') {
  3558. cflg = 1; /* Connect */
  3559. stayflg = 1; /* Stay */
  3560. tn_exit = 1; /* Telnet-like exit condition */
  3561. exitonclose = 1;
  3562. }
  3563. #endif /* NETCONN */
  3564. ckstrncpy(ttname,*xargv,TTNAMLEN+1);
  3565. local = (strcmp(ttname,CTTNAM) != 0);
  3566. if (local && strcmp(ttname,"0") == 0)
  3567. local = 0;
  3568. /*
  3569. NOTE: We really do not need to call ttopen here, since it should be called
  3570. again later, automatically, when we first try to condition the device via
  3571. ttpkt or ttvt. Calling ttopen here has the bad side effect of making the
  3572. order of the -b and -l options significant when the order of command-line
  3573. options should not matter. However, the network cases immediately below
  3574. complicate matters a bit, so we'll settle this in a future edit.
  3575. */
  3576. if (x == 'l') {
  3577. if (ttopen(ttname,&local,mdmtyp,0) < 0) {
  3578. XFATAL("can't open device");
  3579. }
  3580. #ifdef CKLOGDIAL
  3581. dologline();
  3582. #endif /* CKLOGDIAL */
  3583. debug(F101,"doarg speed","",speed);
  3584. cxtype = (mdmtyp > 0) ? CXT_MODEM : CXT_DIRECT;
  3585. speed = ttgspd(); /* Get the speed. */
  3586. setflow(); /* Do something about flow control. */
  3587. #ifndef NOSPL
  3588. if (local) {
  3589. if (nmac) { /* Any macros defined? */
  3590. int k; /* Yes */
  3591. k = mlook(mactab,"on_open",nmac); /* Look this up */
  3592. if (k >= 0) { /* If found, */
  3593. if (dodo(k,ttname,0) > -1) /* set it up, */
  3594. parser(1); /* and execute it */
  3595. }
  3596. }
  3597. }
  3598. #endif /* NOSPL */
  3599. #ifdef NETCONN
  3600. } else {
  3601. if (x == 'j' || x == 'J') { /* IP network host name */
  3602. char * s = line;
  3603. char * service = tmpbuf;
  3604. if (xargc > 0) { /* Check if it's followed by */
  3605. /* A service name or number */
  3606. if (*(xargv+1) && *(*(xargv+1)) != '-') {
  3607. xargv++, xargc--;
  3608. ckstrncat(ttname,":",TTNAMLEN+1);
  3609. ckstrncat(ttname,*xargv,TTNAMLEN+1);
  3610. }
  3611. }
  3612. nettype = NET_TCPB;
  3613. mdmtyp = -nettype; /* Perhaps already set in init file */
  3614. telnetfd = 1; /* Or maybe an open file descriptor */
  3615. ckstrncpy(line, ttname, LINBUFSIZ); /* Working copy */
  3616. for (s = line; *s != NUL && *s != ':'; s++);
  3617. if (*s) {
  3618. *s++ = NUL;
  3619. ckstrncpy(service, s, TMPBUFSIZ);
  3620. } else *service = NUL;
  3621. s = line;
  3622. #ifndef NODIAL
  3623. #ifndef NOICP
  3624. /* Look up in network directory */
  3625. x = 0;
  3626. if (*s == '=') { /* If number starts with = sign */
  3627. s++; /* strip it */
  3628. while (*s == SP) /* and also any leading spaces */
  3629. s++;
  3630. ckstrncpy(line,s,LINBUFSIZ); /* Do this again. */
  3631. nhcount = 0;
  3632. } else if (!isdigit(line[0])) {
  3633. /*
  3634. nnetdir will be greater than 0 if the init file has been processed and it
  3635. contained a SET NETWORK DIRECTORY command.
  3636. */
  3637. xx = 0; /* Initialize this */
  3638. if (nnetdir > 0) /* If there is a directory... */
  3639. xx = lunet(line); /* Look up the name */
  3640. else /* If no directory */
  3641. nhcount = 0; /* we didn't find anything there */
  3642. if (xx < 0) { /* Lookup error: */
  3643. ckmakmsg(tmpbuf,
  3644. TMPBUFSIZ,
  3645. "?Fatal network directory lookup error - ",
  3646. line,
  3647. "\n",
  3648. NULL
  3649. );
  3650. XFATAL(tmpbuf);
  3651. }
  3652. }
  3653. #endif /* NOICP */
  3654. #endif /* NODIAL */
  3655. /* Add service to line specification for ttopen() */
  3656. if (*service) { /* There is a service specified */
  3657. ckstrncat(line, ":",LINBUFSIZ);
  3658. ckstrncat(line, service,LINBUFSIZ);
  3659. ttnproto = NP_DEFAULT;
  3660. } else {
  3661. ckstrncat(line, ":telnet",LINBUFSIZ);
  3662. ttnproto = NP_TELNET;
  3663. }
  3664. #ifndef NOICP
  3665. #ifndef NODIAL
  3666. if ((nhcount > 1) && !quiet && !backgrd) {
  3667. printf("%d entr%s found for \"%s\"%s\n",
  3668. nhcount,
  3669. (nhcount == 1) ? "y" : "ies",
  3670. s,
  3671. (nhcount > 0) ? ":" : "."
  3672. );
  3673. for (i = 0; i < nhcount; i++)
  3674. printf("%3d. %s %-12s => %s\n",
  3675. i+1, n_name, nh_p2[i], nh_p[i]
  3676. );
  3677. }
  3678. if (nhcount == 0)
  3679. n = 1;
  3680. else
  3681. n = nhcount;
  3682. #else
  3683. n = 1;
  3684. nhcount = 0;
  3685. #endif /* NODIAL */
  3686. for (i = 0; i < n; i++) {
  3687. #ifndef NODIAL
  3688. if (nhcount >= 1) {
  3689. /* Copy the current entry to line */
  3690. ckstrncpy(line,nh_p[i],LINBUFSIZ);
  3691. /* Check to see if the network entry contains a service */
  3692. for (s = line ; (*s != NUL) && (*s != ':'); s++)
  3693. ;
  3694. /* If directory does not have a service ... */
  3695. /* and the user specified one */
  3696. if (!*s && *service) {
  3697. ckstrncat(line, ":",LINBUFSIZ);
  3698. ckstrncat(line, service,LINBUFSIZ);
  3699. }
  3700. if (lookup(netcmd,nh_p2[i],nnets,&z) > -1) {
  3701. mdmtyp = 0 - netcmd[z].kwval;
  3702. } else {
  3703. printf(
  3704. "Error - network type \"%s\" not supported\n",
  3705. nh_p2[i]
  3706. );
  3707. continue;
  3708. }
  3709. }
  3710. #endif /* NODIAL */
  3711. }
  3712. #endif /* NOICP */
  3713. ckstrncpy(ttname, line,TTNAMLEN+1);
  3714. cxtype = CXT_TCPIP; /* Set connection type */
  3715. setflow(); /* Set appropriate flow control. */
  3716. #ifdef SUNX25
  3717. } else if (x == 'X') { /* X.25 address */
  3718. nettype = NET_SX25;
  3719. mdmtyp = -nettype;
  3720. } else if (x == 'Z') { /* Open X.25 file descriptor */
  3721. nettype = NET_SX25;
  3722. mdmtyp = -nettype;
  3723. x25fd = 1;
  3724. #endif /* SUNX25 */
  3725. #ifdef STRATUSX25
  3726. } else if (x == 'X') { /* X.25 address */
  3727. nettype = NET_VX25;
  3728. mdmtyp = -nettype;
  3729. #endif /* STRATUSX25 */
  3730. #ifdef IBMX25
  3731. } else if (x == 'X') { /* X.25 address */
  3732. nettype = NET_IX25;
  3733. mdmtyp = -nettype;
  3734. #endif /* IBMX25 */
  3735. #ifdef HPX25
  3736. } else if (x == 'X') { /* X.25 address */
  3737. nettype = NET_HX25;
  3738. mdmtyp = -nettype;
  3739. #endif /* HPX25 */
  3740. }
  3741. if (ttopen(ttname,&local,mdmtyp,0) < 0) {
  3742. XFATAL("can't open host connection");
  3743. }
  3744. network = 1;
  3745. #ifdef CKLOGDIAL
  3746. dolognet();
  3747. #endif /* CKLOGDIAL */
  3748. cxtype = CXT_X25; /* Set connection type */
  3749. setflow(); /* Set appropriate flow control. */
  3750. #ifndef NOSPL
  3751. if (local) {
  3752. if (nmac) { /* Any macros defined? */
  3753. int k; /* Yes */
  3754. k = mlook(mactab,"on_open",nmac); /* Look this up */
  3755. if (k >= 0) { /* If found, */
  3756. if (dodo(k,ttname,0) > -1) /* set it up, */
  3757. parser(1); /* and execute it */
  3758. }
  3759. }
  3760. }
  3761. #endif /* NOSPL */
  3762. #endif /* NETCONN */
  3763. }
  3764. /* add more here -- decnet, etc... */
  3765. haveline = 1;
  3766. break;
  3767. #ifdef ANYX25
  3768. case 'U': /* X.25 call user data */
  3769. if (*(xp+1)) {
  3770. XFATAL("invalid argument bundling");
  3771. }
  3772. xargv++, xargc--;
  3773. if ((xargc < 1) || (**xargv == '-')) {
  3774. XFATAL("missing call user data string");
  3775. }
  3776. ckstrncpy(udata,*xargv,MAXCUDATA);
  3777. if ((int)strlen(udata) <= MAXCUDATA) {
  3778. cudata = 1;
  3779. } else {
  3780. XFATAL("Invalid call user data");
  3781. }
  3782. break;
  3783. case 'o': /* X.25 closed user group */
  3784. if (*(xp+1)) {
  3785. XFATAL("invalid argument bundling");
  3786. }
  3787. xargv++, xargc--;
  3788. if ((xargc < 1) || (**xargv == '-')) {
  3789. XFATAL("missing closed user group index");
  3790. }
  3791. z = atoi(*xargv); /* Convert to number */
  3792. if (z >= 0 && z <= 99) {
  3793. closgr = z;
  3794. } else {
  3795. XFATAL("Invalid closed user group index");
  3796. }
  3797. break;
  3798. case 'u': /* X.25 reverse charge call */
  3799. revcall = 1;
  3800. break;
  3801. #endif /* ANYX25 */
  3802. #endif /* NOLOCAL */
  3803. case 'b': /* Bits-per-second for serial device */
  3804. if (*(xp+1)) {
  3805. XFATAL("invalid argument bundling");
  3806. }
  3807. xargv++, xargc--;
  3808. if ((xargc < 1) || (**xargv == '-')) {
  3809. XFATAL("missing bps");
  3810. }
  3811. zz = atol(*xargv); /* Convert to long int */
  3812. i = zz / 10L;
  3813. #ifndef NOLOCAL
  3814. if (ttsspd(i) > -1) /* Check and set it */
  3815. #endif /* NOLOCAL */
  3816. speed = ttgspd(); /* and read it back. */
  3817. #ifndef NOLOCAL
  3818. else {
  3819. XFATAL("unsupported transmission rate");
  3820. }
  3821. #endif /* NOLOCAL */
  3822. break;
  3823. #ifndef NODIAL
  3824. #ifndef NOICP
  3825. case 'm': /* Modem type */
  3826. if (*(xp+1)) {
  3827. XFATAL("invalid argument bundling after -m");
  3828. }
  3829. xargv++, xargc--;
  3830. if ((xargc < 1) || (**xargv == '-')) {
  3831. XFATAL("modem type missing");
  3832. }
  3833. y = lookup(mdmtab,*xargv,nmdm,&z);
  3834. if (y < 0) {
  3835. XFATAL("unknown modem type");
  3836. }
  3837. usermdm = 0;
  3838. usermdm = (y == dialudt) ? x : 0;
  3839. initmdm(y);
  3840. break;
  3841. #endif /* NOICP */
  3842. #endif /* NODIAL */
  3843. #ifndef NOXFER
  3844. case 'e': /* Extended packet length */
  3845. if (*(xp+1)) {
  3846. XFATAL("invalid argument bundling after -e");
  3847. }
  3848. xargv++, xargc--;
  3849. if ((xargc < 1) || (**xargv == '-')) {
  3850. XFATAL("missing length");
  3851. }
  3852. z = atoi(*xargv); /* Convert to number */
  3853. if (z > 10 && z <= maxrps) {
  3854. rpsiz = urpsiz = z;
  3855. if (z > 94) rpsiz = 94; /* Fallback if other Kermit can't */
  3856. } else {
  3857. XFATAL("Unsupported packet length");
  3858. }
  3859. break;
  3860. case 'v': /* Vindow size */
  3861. if (*(xp+1)) {
  3862. XFATAL("invalid argument bundling");
  3863. }
  3864. xargv++, xargc--;
  3865. if ((xargc < 1) || (**xargv == '-')) {
  3866. XFATAL("missing or bad window size");
  3867. }
  3868. z = atoi(*xargv); /* Convert to number */
  3869. if (z < 32) { /* If in range */
  3870. wslotr = z; /* set it */
  3871. if (z > 1) swcapr = 1; /* Set capas bit if windowing */
  3872. } else {
  3873. XFATAL("Unsupported packet length");
  3874. }
  3875. break;
  3876. #endif /* NOXFER */
  3877. case 'i': /* Treat files as binary */
  3878. binary = XYFT_B;
  3879. xfermode = XMODE_M; /* Transfer mode manual */
  3880. filepeek = 0;
  3881. #ifdef PATTERNS
  3882. patterns = 0;
  3883. #endif /* PATTERNS */
  3884. break;
  3885. #ifndef NOXFER
  3886. case 'w': /* Writeover */
  3887. ckwarn = 0;
  3888. fncact = XYFX_X;
  3889. break;
  3890. #endif /* NOXFER */
  3891. case 'q': /* Quiet */
  3892. quiet = 1;
  3893. break;
  3894. #ifdef DEBUG
  3895. case 'd': /* DEBUG */
  3896. break; /* Handled in prescan() */
  3897. #endif /* DEBUG */
  3898. case '0': { /* In the middle */
  3899. extern int tt_escape, lscapr;
  3900. tt_escape = 0; /* No escape character */
  3901. flow = 0; /* No Xon/Xoff (what about hwfc?) */
  3902. #ifndef NOXFER
  3903. lscapr = 0; /* No locking shifts */
  3904. #endif /* NOXFER */
  3905. #ifdef CK_APC
  3906. {
  3907. extern int apcstatus; /* No APCs */
  3908. apcstatus = APC_OFF;
  3909. }
  3910. #endif /* CK_APC */
  3911. #ifndef NOLOCAL
  3912. #ifdef CK_AUTODL
  3913. setautodl(0,0); /* No autodownload */
  3914. #endif /* CK_AUTODL */
  3915. #endif /* NOLOCAL */
  3916. #ifndef NOCSETS
  3917. {
  3918. extern int tcsr, tcsl; /* No character-set translation */
  3919. tcsr = 0;
  3920. tcsl = tcsr; /* Make these equal */
  3921. }
  3922. #endif /* NOCSETS */
  3923. #ifdef TNCODE
  3924. TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
  3925. TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
  3926. TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
  3927. TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
  3928. #endif /* TNCODE */
  3929. }
  3930. /* Fall thru... */
  3931. case '8': /* 8-bit clean */
  3932. parity = 0;
  3933. cmdmsk = 0xff;
  3934. cmask = 0xff;
  3935. break;
  3936. case 'V': {
  3937. extern int xfermode;
  3938. #ifdef PATTERNS
  3939. extern int patterns;
  3940. patterns = 0; /* No patterns */
  3941. #endif /* PATTERNS */
  3942. xfermode = XMODE_M; /* Manual transfer mode */
  3943. filepeek = 0;
  3944. break;
  3945. }
  3946. case 'p': /* SET PARITY */
  3947. if (*(xp+1)) {
  3948. XFATAL("invalid argument bundling");
  3949. }
  3950. xargv++, xargc--;
  3951. if ((xargc < 1) || (**xargv == '-')) {
  3952. XFATAL("missing parity");
  3953. }
  3954. switch(x = **xargv) {
  3955. case 'e':
  3956. case 'o':
  3957. case 'm':
  3958. case 's': parity = x; break;
  3959. case 'n': parity = 0; break;
  3960. default: { XFATAL("invalid parity"); }
  3961. }
  3962. break;
  3963. case 't': /* Line turnaround handshake */
  3964. turn = 1;
  3965. turnch = XON; /* XON is turnaround character */
  3966. duplex = 1; /* Half duplex */
  3967. flow = 0; /* No flow control */
  3968. break;
  3969. case 'B':
  3970. bgset = 1; /* Force background (batch) */
  3971. backgrd = 1;
  3972. break;
  3973. case 'z': /* Force foreground */
  3974. bgset = 0;
  3975. backgrd = 0;
  3976. break;
  3977. #ifndef NOXFER
  3978. #ifdef RECURSIVE
  3979. case 'L':
  3980. recursive = 2;
  3981. nolinks = 2;
  3982. fnspath = PATH_REL;
  3983. break;
  3984. #endif /* RECURSIVE */
  3985. #endif /* NOXFER */
  3986. #ifndef NOSPL
  3987. case 'M': /* My User Name */
  3988. if (*(xp+1)) {
  3989. XFATAL("invalid argument bundling");
  3990. }
  3991. xargv++, xargc--;
  3992. if ((xargc < 1) || (**xargv == '-')) {
  3993. XFATAL("missing username");
  3994. }
  3995. if ((int)strlen(*xargv) > 63) {
  3996. XFATAL("username too long");
  3997. }
  3998. #ifdef IKSD
  3999. if (!inserver)
  4000. #endif /* IKSD */
  4001. {
  4002. ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
  4003. haveftpuid = 1;
  4004. }
  4005. break;
  4006. #endif /* NOSPL */
  4007. #ifdef CK_NETBIOS
  4008. case 'N': /* NetBios Adapter Number follows */
  4009. if (*(xp+1)) {
  4010. XFATAL("invalid argument bundling after -N");
  4011. }
  4012. xargv++, xargc--;
  4013. if ((xargc < 1) || (**xargv == '-')) {
  4014. XFATAL("missing NetBios Adapter number");
  4015. }
  4016. if ((strlen(*xargv) != 1) ||
  4017. (*xargv)[0] != 'X' &&
  4018. (atoi(*xargv) < 0) &&
  4019. (atoi(*xargv) > 9)) {
  4020. XFATAL("Invalid NetBios Adapter - Adapters 0 to 9 are valid");
  4021. }
  4022. break;
  4023. #endif /* CK_NETBIOS */
  4024. #ifdef NETCONN
  4025. case 'F':
  4026. network = 1;
  4027. if (*(xp+1)) {
  4028. XFATAL("invalid argument bundling after -F");
  4029. }
  4030. xargv++, xargc--;
  4031. if ((xargc < 1) || (**xargv == '-')) {
  4032. XFATAL("network file descriptor missing");
  4033. }
  4034. ckstrncpy(ttname,*xargv,TTNAMLEN+1);
  4035. nettype = NET_TCPB;
  4036. mdmtyp = -nettype;
  4037. telnetfd = 1;
  4038. local = 1;
  4039. break;
  4040. #endif /* NETCONN */
  4041. #ifdef COMMENT
  4042. #ifdef OS2PM
  4043. case 'P': /* OS/2 Presentation Manager */
  4044. if (*(xp+1)) {
  4045. XFATAL("invalid argument bundling after -P");
  4046. }
  4047. xargv++, xargc--;
  4048. if ((xargc < 1) || (**xargv == '-')) {
  4049. XFATAL("pipe data missing");
  4050. }
  4051. pipedata = *xargv;
  4052. break;
  4053. #endif /* OS2PM */
  4054. #else
  4055. case 'P': /* Filenames literal */
  4056. fncnv = XYFN_L;
  4057. f_save = XYFN_L;
  4058. break;
  4059. #endif /* COMMENT */
  4060. #ifndef NOICP
  4061. case 'H':
  4062. noherald = 1;
  4063. break;
  4064. #endif /* NOICP */
  4065. #ifdef OS2
  4066. case 'W':
  4067. if (*(xp+1)) {
  4068. XFATAL("invalid argument bundling after -W");
  4069. }
  4070. xargv++, xargc--;
  4071. if ((xargc < 1)) { /* could be negative */
  4072. XFATAL("Window handle missing");
  4073. }
  4074. xargv++, xargc--;
  4075. if ((xargc < 1) || (**xargv == '-')) {
  4076. XFATAL("Kermit Instance missing");
  4077. }
  4078. /* Action done in prescan */
  4079. break;
  4080. case '#': /* K95 stdio threads */
  4081. xargv++, xargc--; /* Skip past argument */
  4082. break; /* Action done in prescan */
  4083. #endif /* OS2 */
  4084. #ifdef NEWFTP
  4085. case '9': /* FTP */
  4086. if (*(xp+1)) {
  4087. XFATAL("invalid argument bundling after -9");
  4088. }
  4089. xargv++, xargc--;
  4090. if ((xargc < 1) || (**xargv == '-')) {
  4091. XFATAL("FTP server address missing");
  4092. }
  4093. makestr(&ftp_host,*xargv);
  4094. break;
  4095. #endif /* NEWFTP */
  4096. default:
  4097. fatal2(*xargv,
  4098. #ifdef NT
  4099. "invalid command-line option, type \"k95 -h\" for help"
  4100. #else
  4101. #ifdef OS2
  4102. "invalid command-line option, type \"k2 -h\" for help"
  4103. #else
  4104. "invalid command-line option, type \"kermit -h\" for help"
  4105. #endif /* OS2 */
  4106. #endif /* NT */
  4107. );
  4108. }
  4109. if (!xp) break;
  4110. x = *++xp; /* See if options are bundled */
  4111. }
  4112. return(0);
  4113. }
  4114. #ifdef TNCODE
  4115. /* D O T N A R G -- Do a telnet command-line argument. */
  4116. static int
  4117. #ifdef CK_ANSIC
  4118. dotnarg(char x)
  4119. #else
  4120. dotnarg(x) char x;
  4121. #endif /* CK_ANSIC */
  4122. /* dotnarg */ {
  4123. char *xp;
  4124. xp = *xargv+1; /* Pointer for bundled args */
  4125. debug(F111,"dotnarg entry",xp,xargc);
  4126. while (x) {
  4127. debug(F000,"dotnarg arg","",x);
  4128. switch (x) { /* Big switch on arg */
  4129. #ifndef COMMENT
  4130. case '-': /* Extended commands... */
  4131. if (doxarg(xargv,0) < 0) {
  4132. XFATAL("Extended option error");
  4133. } /* Full thru... */
  4134. case '+': /* Extended command for prescan() */
  4135. return(0);
  4136. #else /* COMMENT */
  4137. case '-':
  4138. case '+':
  4139. XFATAL("Extended options not configured");
  4140. #endif /* COMMENT */
  4141. /*
  4142. * -# Kermit 95 Startup Flags
  4143. * -8 Negotiate Telnet Binary in both directions
  4144. * -a Require use of Telnet authentication
  4145. * -c Do not read the .telnetrc file
  4146. * -d Turn on debug mode
  4147. * -E No escape character
  4148. * -f Forward credentials to host
  4149. * -K Refuse use of authentication; do not send username
  4150. * -k realm Set default realm
  4151. * -l user Set username and request Telnet authentication
  4152. * -L Negotiate Telnet Binary Output only
  4153. * -q Quiet mode (suppress messages)
  4154. * -S tos Use the IP type-of-service tos
  4155. * -x Require Encryption
  4156. * -D Disable forward-X
  4157. * -T cert=file Use certificate in file
  4158. * -T key=file Use private key in file
  4159. * -T crlfile=file Use CRL in file
  4160. * -T crldir=dir Use CRLs in directory
  4161. * -T cipher=string Use only ciphers in string
  4162. * -X atype Disable use of atype authentication
  4163. * -Y Disable init file processing
  4164. *
  4165. */
  4166. case 'h': /* help */
  4167. usage();
  4168. doexit(GOOD_EXIT,-1);
  4169. break;
  4170. case '8': /* Telnet Binary in both directions */
  4171. TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = TN_NG_MU;
  4172. TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
  4173. parity = 0;
  4174. cmdmsk = 0xff;
  4175. cmask = 0xff;
  4176. break;
  4177. case 'a': /* Require Telnet Auth */
  4178. TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
  4179. break;
  4180. case 'Y':
  4181. xargv++, xargc--; /* Skip past argument */
  4182. break; /* Action done in prescan */
  4183. #ifdef OS2
  4184. case '#': /* K95 stdio threads */
  4185. xargv++, xargc--; /* Skip past argument */
  4186. break; /* Action done in prescan */
  4187. #endif /* OS2 */
  4188. case 'q': /* Quiet */
  4189. quiet = 1;
  4190. break;
  4191. case 'd':
  4192. #ifdef DEBUG
  4193. if (deblog) {
  4194. debtim = 1;
  4195. } else {
  4196. deblog = debopn("debug.log",0);
  4197. }
  4198. #endif /* DEBUG */
  4199. break;
  4200. case 'E': { /* No Escape character */
  4201. extern int tt_escape;
  4202. tt_escape = 0;
  4203. }
  4204. break;
  4205. case 'K':
  4206. TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_RF;
  4207. uidbuf[0] = NUL;
  4208. break;
  4209. case 'l': /* Set username and request telnet authentication */
  4210. if (*(xp+1)) {
  4211. XFATAL("invalid argument bundling");
  4212. }
  4213. xargv++, xargc--;
  4214. if ((xargc < 1) || (**xargv == '-')) {
  4215. XFATAL("missing username");
  4216. }
  4217. if ((int)strlen(*xargv) > 63) {
  4218. XFATAL("username too long");
  4219. }
  4220. ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
  4221. TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
  4222. break;
  4223. case 'L': /* Require BINARY mode outbound only */
  4224. TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
  4225. break;
  4226. case 'x': /* Require Encryption */
  4227. TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
  4228. TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
  4229. break;
  4230. case 'D': /* Disable use of Forward X */
  4231. TELOPT_DEF_C_U_MODE(TELOPT_FORWARD_X) = TN_NG_RF;
  4232. break;
  4233. case 'f': /* Forward credentials to host */
  4234. {
  4235. #ifdef CK_AUTHENTICATION
  4236. extern int forward_flag;
  4237. forward_flag = 1;
  4238. #endif
  4239. break;
  4240. }
  4241. case 'k': {
  4242. #ifdef CK_KERBEROS
  4243. extern char * krb5_d_realm, * krb4_d_realm;
  4244. #endif /* CK_KERBEROS */
  4245. if (*(xp+1)) {
  4246. XFATAL("invalid argument bundling");
  4247. }
  4248. xargv++, xargc--;
  4249. if ((xargc < 1) || (**xargv == '-')) {
  4250. XFATAL("missing realm");
  4251. }
  4252. #ifdef CK_KERBEROS
  4253. if ((int)strlen(*xargv) > 63) {
  4254. XFATAL("realm too long");
  4255. }
  4256. makestr(&krb5_d_realm,*xargv);
  4257. makestr(&krb4_d_realm,*xargv);
  4258. #endif /* CK_KERBEROS */
  4259. break;
  4260. }
  4261. case 'T': {
  4262. if (*(xp+1)) {
  4263. XFATAL("invalid argument bundling");
  4264. }
  4265. xargv++, xargc--;
  4266. if ((xargc < 1) || (**xargv == '-')) {
  4267. XFATAL("missing cert=, key=, crlfile=, crldir=, or cipher=");
  4268. }
  4269. #ifdef CK_SSL
  4270. if (!strncmp(*xargv,"cert=",5)) {
  4271. extern char * ssl_rsa_cert_file;
  4272. makestr(&ssl_rsa_cert_file,&(*xargv[5]));
  4273. } else if ( !strncmp(*xargv,"key=",4) ) {
  4274. extern char * ssl_rsa_key_file;
  4275. makestr(&ssl_rsa_key_file,&(*xargv[4]));
  4276. } else if ( !strncmp(*xargv,"crlfile=",8) ) {
  4277. extern char * ssl_crl_file;
  4278. makestr(&ssl_crl_file,&(*xargv[8]));
  4279. } else if ( !strncmp(*xargv,"crldir=",7) ) {
  4280. extern char * ssl_crl_dir;
  4281. makestr(&ssl_crl_dir,&(*xargv[7]));
  4282. } else if ( !strncmp(*xargv,"cipher=",7) ) {
  4283. extern char * ssl_cipher_list;
  4284. makestr(&ssl_cipher_list,&(*xargv[7]));
  4285. } else {
  4286. XFATAL("invalid parameter");
  4287. }
  4288. #endif /* CK_SSL */
  4289. break;
  4290. }
  4291. default:
  4292. fatal2(*xargv,
  4293. "invalid command-line option, type \"telnet -h\" for help"
  4294. );
  4295. }
  4296. if (!xp) break;
  4297. x = *++xp; /* See if options are bundled */
  4298. }
  4299. return(0);
  4300. }
  4301. #endif /* TNCODE */
  4302. #ifdef RLOGCODE
  4303. /* D O R L G A R G -- Do a rlogin command-line argument. */
  4304. static int
  4305. #ifdef CK_ANSIC
  4306. dorlgarg(char x)
  4307. #else
  4308. dorlgarg(x) char x;
  4309. #endif /* CK_ANSIC */
  4310. /* dorlgarg */ {
  4311. char *xp;
  4312. xp = *xargv+1; /* Pointer for bundled args */
  4313. debug(F111,"dorlgarg entry",xp,xargc);
  4314. while (x) {
  4315. debug(F000,"dorlgarg arg","",x);
  4316. switch (x) { /* Big switch on arg */
  4317. #ifndef COMMENT
  4318. case '-': /* Extended commands... */
  4319. if (doxarg(xargv,0) < 0) {
  4320. XFATAL("Extended option error");
  4321. } /* Full thru... */
  4322. case '+': /* Extended command for prescan() */
  4323. return(0);
  4324. #else /* COMMENT */
  4325. case '-':
  4326. case '+':
  4327. XFATAL("Extended options not configured");
  4328. #endif /* COMMENT */
  4329. /*
  4330. * -d Debug
  4331. * -l user Set username
  4332. *
  4333. */
  4334. case 'h': /* help */
  4335. usage();
  4336. doexit(GOOD_EXIT,-1);
  4337. break;
  4338. case 'Y':
  4339. xargv++, xargc--; /* Skip past argument */
  4340. break; /* Action done in prescan */
  4341. #ifdef OS2
  4342. case '#': /* K95 stdio threads */
  4343. xargv++, xargc--; /* Skip past argument */
  4344. break; /* Action done in prescan */
  4345. #endif /* OS2 */
  4346. case 'q': /* Quiet */
  4347. quiet = 1;
  4348. break;
  4349. case 'd':
  4350. #ifdef DEBUG
  4351. if (deblog) {
  4352. debtim = 1;
  4353. } else {
  4354. deblog = debopn("debug.log",0);
  4355. }
  4356. #endif /* DEBUG */
  4357. break;
  4358. case 'l': /* Set username and request telnet authentication */
  4359. if (*(xp+1)) {
  4360. XFATAL("invalid argument bundling");
  4361. }
  4362. xargv++, xargc--;
  4363. if ((xargc < 1) || (**xargv == '-')) {
  4364. XFATAL("missing username");
  4365. }
  4366. if ((int)strlen(*xargv) > 63) {
  4367. XFATAL("username too long");
  4368. }
  4369. ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
  4370. break;
  4371. default:
  4372. fatal2(*xargv,
  4373. "invalid command-line option, type \"rlogin -h\" for help"
  4374. );
  4375. }
  4376. if (!xp) break;
  4377. x = *++xp; /* See if options are bundled */
  4378. }
  4379. return(0);
  4380. }
  4381. #endif /* RLOGCODE */
  4382. #ifdef SSHBUILTIN
  4383. /* D O S S H A R G -- Do a ssh command-line argument. */
  4384. static int
  4385. #ifdef CK_ANSIC
  4386. dossharg(char x)
  4387. #else
  4388. dossharg(x) char x;
  4389. #endif /* CK_ANSIC */
  4390. /* dossharg */ {
  4391. char *xp;
  4392. xp = *xargv+1; /* Pointer for bundled args */
  4393. debug(F111,"dossharg entry",xp,xargc);
  4394. while (x) {
  4395. debug(F000,"dossharg arg","",x);
  4396. switch (x) { /* Big switch on arg */
  4397. #ifndef COMMENT
  4398. case '-': /* Extended commands... */
  4399. if (doxarg(xargv,0) < 0) {
  4400. XFATAL("Extended option error");
  4401. } /* Full thru... */
  4402. case '+': /* Extended command for prescan() */
  4403. return(0);
  4404. #else /* COMMENTP */
  4405. case '-':
  4406. case '+':
  4407. XFATAL("Extended options not configured");
  4408. #endif /* COMMENT */
  4409. /*
  4410. * -d Debug
  4411. * -# args Init
  4412. * -Y no init file
  4413. * -l user Set username
  4414. *
  4415. */
  4416. case 'h': /* help */
  4417. usage();
  4418. doexit(GOOD_EXIT,-1);
  4419. break;
  4420. case 'Y':
  4421. xargv++, xargc--; /* Skip past argument */
  4422. break; /* Action done in prescan */
  4423. #ifdef OS2
  4424. case '#': /* K95 stdio threads */
  4425. xargv++, xargc--; /* Skip past argument */
  4426. break; /* Action done in prescan */
  4427. #endif /* OS2 */
  4428. case 'q': /* Quiet */
  4429. quiet = 1;
  4430. break;
  4431. case 'd':
  4432. #ifdef DEBUG
  4433. if (deblog) {
  4434. debtim = 1;
  4435. } else {
  4436. deblog = debopn("debug.log",0);
  4437. }
  4438. #endif /* DEBUG */
  4439. break;
  4440. case 'l': /* Set username and request telnet authentication */
  4441. if (*(xp+1)) {
  4442. XFATAL("invalid argument bundling");
  4443. }
  4444. xargv++, xargc--;
  4445. if ((xargc < 1) || (**xargv == '-')) {
  4446. XFATAL("missing username");
  4447. }
  4448. if ((int)strlen(*xargv) > 63) {
  4449. XFATAL("username too long");
  4450. }
  4451. ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
  4452. break;
  4453. default:
  4454. fatal2(*xargv,
  4455. "invalid command-line option, type \"ssh -h\" for help"
  4456. );
  4457. }
  4458. if (!xp) break;
  4459. x = *++xp; /* See if options are bundled */
  4460. }
  4461. return(0);
  4462. }
  4463. #endif /* SSHBUILTIN */
  4464. #else /* No command-line interface... */
  4465. int
  4466. cmdlin() {
  4467. extern int xargc;
  4468. if (xargc > 1) {
  4469. XFATAL("Sorry, command-line options disabled.");
  4470. }
  4471. }
  4472. #endif /* NOCMDL */