install.pas 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. {
  2. $Id$
  3. This file is part of Free Pascal
  4. Copyright (c) 1993-2000 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. This is the install program for Free Pascal
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. program install;
  14. {$DEFINE FV} (* TH - added to make use of the original Turbo Vision possible. *)
  15. { $DEFINE DLL} (* TH - if defined, UNZIP32.DLL library is used to unpack. *)
  16. { $DEFINE DOSSTUB} (* TH - should _not_ be defined unless creating a bound DOS and OS/2 installer!!! *)
  17. (* Defining DOSSTUB causes adding a small piece of code *)
  18. (* for starting the OS/2 part from the DOS part of a bound *)
  19. (* application if running in OS/2 VDM (DOS) window. Used *)
  20. (* only if compiling with TP/BP (see conditionals below). *)
  21. {$IFDEF VER60}
  22. {$DEFINE TP}
  23. {$ENDIF}
  24. {$IFDEF VER70}
  25. {$DEFINE TP}
  26. {$ENDIF}
  27. {$IFNDEF TP}
  28. {$UNDEF DOSSTUB}
  29. {$ELSE}
  30. {$IFDEF OS2}
  31. {$UNDEF DOSSTUB}
  32. {$ENDIF}
  33. {$ENDIF}
  34. {$IFDEF DPMI}
  35. {$UNDEF DOSSTUB}
  36. {$ENDIF}
  37. uses
  38. {$IFDEF OS2}
  39. {$IFDEF FPC}
  40. DosCalls,
  41. {$ELSE FPC}
  42. {$IFDEF VirtualPascal}
  43. OS2Base,
  44. {$ELSE VirtualPascal}
  45. BseDos,
  46. {$ENDIF VirtualPascal}
  47. {$ENDIF FPC}
  48. {$ENDIF OS2}
  49. {$IFDEF GO32V2}
  50. emu387,
  51. {$ENDIF}
  52. {$ifdef HEAPTRC}
  53. heaptrc,
  54. {$endif HEAPTRC}
  55. strings,dos,objects,drivers,
  56. {$IFDEF FV}
  57. commands,
  58. {$ENDIF}
  59. unzip,ziptypes,
  60. {$IFDEF DLL}
  61. unzipdll,
  62. {$ENDIF}
  63. app,dialogs,views,menus,msgbox,colortxt,tabs,inststr,scroll,
  64. HelpCtx,WHTMLScn;
  65. const
  66. installerversion='1.0.2';
  67. {$ifdef TP}lfnsupport=false;{$endif}
  68. maxpacks=10;
  69. maxpackages=20;
  70. maxdefcfgs=1024;
  71. HTMLIndexExt = '.htx';
  72. CfgExt = '.dat';
  73. MaxStatusPos = 4;
  74. StatusChars: string [MaxStatusPos] = '/-\|';
  75. StatusPos: byte = 1;
  76. { this variable is set to true if an ide is installed }
  77. haside : boolean = false;
  78. hashtmlhelp : boolean = false;
  79. {$IFDEF LINUX}
  80. DirSep='/';
  81. {$ELSE}
  82. {$IFDEF UNIX}
  83. DirSep='/';
  84. {$ELSE}
  85. DirSep='\';
  86. {$ENDIF}
  87. {$ENDIF}
  88. {$IFNDEF GO32V2}
  89. {$IFDEF GO32V1}
  90. LFNSupport = false;
  91. {$ELSE}
  92. {$IFDEF TP}
  93. LFNSupport = false;
  94. {$ELSE}
  95. LFNSupport = true;
  96. {$ENDIF}
  97. {$ENDIF}
  98. {$ENDIF}
  99. type
  100. tpackage=record
  101. name : string[60];
  102. zip : string[12];
  103. end;
  104. tpack=record
  105. name : string[12];
  106. binsub : string[40];
  107. ppc386 : string[20];
  108. defidecfgfile,
  109. defideinifile,
  110. defcfgfile : string[12];
  111. include : boolean;
  112. filechk : string[40];
  113. packages : longint;
  114. package : array[1..maxpackages] of tpackage;
  115. end;
  116. tcfgarray = array[1..maxdefcfgs] of pstring;
  117. cfgrec=record
  118. title : string[80];
  119. version : string[20];
  120. language : string[30];
  121. helpidx,
  122. docsub,
  123. basepath : DirStr;
  124. packs : word;
  125. pack : array[1..maxpacks] of tpack;
  126. defideinis,
  127. defidecfgs,
  128. defcfgs : longint;
  129. defideini,
  130. defidecfg,
  131. defcfg : tcfgarray;
  132. end;
  133. datarec=packed record
  134. basepath : DirStr;
  135. cfgval : word;
  136. packmask : array[1..maxpacks] of word;
  137. end;
  138. punzipdialog=^tunzipdialog;
  139. tunzipdialog=object(tdialog)
  140. filetext : pstatictext;
  141. extractfiletext : pstatictext;
  142. constructor Init(var Bounds: TRect; ATitle: TTitleStr);
  143. procedure do_unzip(s,topath:string);
  144. end;
  145. penddialog = ^tenddialog;
  146. tenddialog = object(tdialog)
  147. constructor init;
  148. end;
  149. pinstalldialog = ^tinstalldialog;
  150. tinstalldialog = object(tdialog)
  151. constructor init;
  152. end;
  153. planguagedialog = ^tlanguagedialog;
  154. tlanguagedialog = object(tdialog)
  155. constructor init;
  156. end;
  157. PFPHTMLFileLinkScanner = ^TFPHTMLFileLinkScanner;
  158. TFPHTMLFileLinkScanner = object(THTMLFileLinkScanner)
  159. function CheckURL(const URL: string): boolean; virtual;
  160. function CheckText(const Text: string): boolean; virtual;
  161. procedure ProcessDoc(Doc: PHTMLLinkScanFile); virtual;
  162. end;
  163. phtmlindexdialog = ^thtmlindexdialog;
  164. thtmlindexdialog = object(tdialog)
  165. text : pstatictext;
  166. constructor init(var Bounds: TRect; ATitle: TTitleStr);
  167. end;
  168. tapp = object(tapplication)
  169. procedure initmenubar;virtual;
  170. procedure handleevent(var event : tevent);virtual;
  171. procedure do_installdialog;
  172. procedure do_languagedialog;
  173. procedure readcfg(const fn:string);
  174. procedure checkavailpack;
  175. end;
  176. {$IFDEF DOSSTUB}
  177. PByte = ^byte;
  178. PRunBlock = ^TRunBlock;
  179. TRunBlock = record
  180. Length: word;
  181. Dependent: word;
  182. Background: word;
  183. TraceLevel: word;
  184. PrgTitle: PChar;
  185. PrgName: PChar;
  186. Args: PChar;
  187. TermQ: longint;
  188. Environment: pointer;
  189. Inheritance: word;
  190. SesType: word;
  191. Icon: pointer;
  192. PgmHandle: longint;
  193. PgmControl: word;
  194. Column: word;
  195. Row: word;
  196. Width: word;
  197. Height: word;
  198. end;
  199. {$ENDIF}
  200. var
  201. installapp : tapp;
  202. startpath : string;
  203. successfull : boolean;
  204. cfg : cfgrec;
  205. data : datarec;
  206. CfgName: NameStr;
  207. DStr: DirStr;
  208. EStr: ExtStr;
  209. UnzDlg : punzipdialog;
  210. log : text;
  211. createlog : boolean;
  212. msgfile : string;
  213. {$IFNDEF DLL}
  214. const
  215. UnzipErr: longint = 0;
  216. {$ENDIF}
  217. {*****************************************************************************
  218. Helpers
  219. *****************************************************************************}
  220. procedure errorhalt;
  221. begin
  222. installapp.done;
  223. halt(1);
  224. end;
  225. function packagemask(i:longint):longint;
  226. begin
  227. packagemask:=1 shl (i-1);
  228. end;
  229. function upper(const s : string):string;
  230. var
  231. i : integer;
  232. begin
  233. for i:=1 to length(s) do
  234. if s[i] in ['a'..'z'] then
  235. upper[i]:=chr(ord(s[i])-32)
  236. else
  237. upper[i]:=s[i];
  238. upper[0]:=s[0];
  239. end;
  240. function Replace(var s:string;const s1,s2:string) : boolean;
  241. var
  242. i : longint;
  243. begin
  244. Replace:=false;
  245. repeat
  246. i:=pos(s1,s);
  247. if i>0 then
  248. begin
  249. Delete(s,i,length(s1));
  250. Insert(s2,s,i);
  251. Replace:=true;
  252. end;
  253. until i=0;
  254. end;
  255. function file_exists(const f : string;const path : string) : boolean;
  256. begin
  257. file_exists:=fsearch(f,path)<>'';
  258. end;
  259. function createdir(s:string):boolean;
  260. var
  261. s1,start : string;
  262. err : boolean;
  263. i : longint;
  264. begin
  265. err:=false;
  266. {$I-}
  267. getdir(0,start);
  268. {$ifndef linux}
  269. if (s[2]=':') and (s[3]=DirSep) then
  270. begin
  271. chdir(Copy(s,1,3));
  272. Delete(S,1,3);
  273. end;
  274. {$endif}
  275. repeat
  276. i:=Pos(DirSep,s);
  277. if i=0 then
  278. i:=255;
  279. s1:=Copy(s,1,i-1);
  280. Delete(s,1,i);
  281. ChDir(s1);
  282. if ioresult<>0 then
  283. begin
  284. mkdir(s1);
  285. chdir(s1);
  286. if ioresult<>0 then
  287. begin
  288. err:=true;
  289. break;
  290. end;
  291. end;
  292. until s='';
  293. chdir(start);
  294. {$I+}
  295. createdir:=err;
  296. end;
  297. function DiskSpaceN(const zipfile : string) : longint;
  298. var
  299. compressed,uncompressed : longint;
  300. s : string;
  301. begin
  302. s:=zipfile+#0;
  303. if not (IsZip (@S [1])) then DiskSpaceN := -1 else
  304. begin
  305. Uncompressed:=UnzipSize(@s[1],compressed);
  306. DiskSpaceN:=uncompressed shr 10;
  307. end;
  308. end;
  309. function diskspace(const zipfile : string) : string;
  310. var
  311. uncompressed : longint;
  312. s : string;
  313. begin
  314. uncompressed:=DiskSpaceN (zipfile);
  315. if Uncompressed = -1 then DiskSpace := str_invalid else
  316. begin
  317. str(uncompressed,s);
  318. diskspace:=' ('+s+' KB)';
  319. end;
  320. end;
  321. function createinstalldir(s : string) : boolean;
  322. var
  323. err : boolean;
  324. dir : searchrec;
  325. params : array[0..0] of pointer;
  326. begin
  327. if s[length(s)]=DirSep then
  328. dec(s[0]);
  329. FindFirst(s,AnyFile,dir);
  330. if doserror=0 then
  331. begin
  332. if Dir.Attr and Directory = 0 then
  333. begin
  334. messagebox(msg_problems_create_dir,nil,
  335. mferror+mfokbutton);
  336. createinstalldir:=false;
  337. end else
  338. createinstalldir:=messagebox(msg_install_dir_exists,nil,
  339. mferror+mfyesbutton+mfnobutton)=cmYes;
  340. exit;
  341. end;
  342. err:=Createdir(s);
  343. if err then
  344. begin
  345. params[0]:=@s;
  346. messagebox(msg_install_cant_be_created,
  347. @params,mferror+mfokbutton);
  348. createinstalldir:=false;
  349. exit;
  350. end;
  351. {$ifndef TP}
  352. {$IFNDEF OS2}
  353. FindClose (dir);
  354. {$ENDIF}
  355. {$endif}
  356. createinstalldir:=true;
  357. end;
  358. function GetProgDir: DirStr;
  359. var
  360. D: DirStr;
  361. N: NameStr;
  362. E: ExtStr;
  363. begin
  364. FSplit (FExpand (ParamStr (0)), D, N, E);
  365. if (D [0] <> #0) and (D [byte (D [0])] = '\') then Dec (D [0]);
  366. GetProgDir := D;
  367. end;
  368. function RTrim(const S: string): string;
  369. var
  370. i : longint;
  371. begin
  372. i:=length(s);
  373. while (i>0) and (s[i]=' ') do
  374. dec(i);
  375. RTrim:=Copy(s,1,i);
  376. end;
  377. function LTrim(const S: string): string;
  378. var
  379. i : longint;
  380. begin
  381. i:=1;
  382. while (i<length(s)) and (s[i]=' ') do
  383. inc(i);
  384. LTrim:=Copy(s,i,255);
  385. end;
  386. function Trim(const S: string): string;
  387. begin
  388. Trim:=RTrim(LTrim(S));
  389. end;
  390. function CompareText(S1, S2: string): integer;
  391. var R: integer;
  392. begin
  393. S1:=Upcase(S1);
  394. S2:=Upcase(S2);
  395. if S1<S2 then R:=-1 else
  396. if S1>S2 then R:= 1 else
  397. R:=0;
  398. CompareText:=R;
  399. end;
  400. function ExtOf(const S: string): string;
  401. var D: DirStr; E: ExtStr; N: NameStr;
  402. begin
  403. FSplit(S,D,N,E);
  404. ExtOf:=E;
  405. end;
  406. function DirAndNameOf(const S: string): string;
  407. var D: DirStr; E: ExtStr; N: NameStr;
  408. begin
  409. FSplit(S,D,N,E);
  410. DirAndNameOf:=D+N;
  411. end;
  412. {*****************************************************************************
  413. HTML-Index Generation
  414. *****************************************************************************}
  415. var
  416. indexdlg : phtmlindexdialog;
  417. constructor thtmlindexdialog.Init(var Bounds: TRect; ATitle: TTitleStr);
  418. var
  419. r : trect;
  420. begin
  421. inherited init(bounds,atitle);
  422. R.Assign (4, 2,bounds.B.X-Bounds.A.X-2, 4);
  423. text:=new(pstatictext,init(r,'Please wait ...'));
  424. insert(text);
  425. end;
  426. procedure TFPHTMLFileLinkScanner.ProcessDoc(Doc: PHTMLLinkScanFile);
  427. var
  428. oldtext : pstring;
  429. begin
  430. oldtext:=indexdlg^.text^.text;
  431. indexdlg^.text^.text:=newstr('Processing '+Doc^.GetDocumentURL);
  432. indexdlg^.text^.drawview;
  433. inherited ProcessDoc(Doc);
  434. disposestr(indexdlg^.text^.text);
  435. indexdlg^.text^.text:=oldtext;
  436. indexdlg^.text^.drawview;
  437. end;
  438. function TFPHTMLFileLinkScanner.CheckURL(const URL: string): boolean;
  439. var OK: boolean;
  440. const HTTPPrefix = 'http:';
  441. FTPPrefix = 'ftp:';
  442. begin
  443. OK:=inherited CheckURL(URL);
  444. if OK then OK:=DirAndNameOf(URL)<>'';
  445. if OK then OK:=CompareText(copy(ExtOf(URL),1,4),'.HTM')=0;
  446. if OK then OK:=CompareText(copy(URL,1,length(HTTPPrefix)),HTTPPrefix)<>0;
  447. if OK then OK:=CompareText(copy(URL,1,length(FTPPrefix)),FTPPrefix)<>0;
  448. CheckURL:=OK;
  449. end;
  450. function TFPHTMLFileLinkScanner.CheckText(const Text: string): boolean;
  451. var OK: boolean;
  452. S: string;
  453. begin
  454. S:=Trim(Text);
  455. OK:=(S<>'') and (copy(S,1,1)<>'[');
  456. CheckText:=OK;
  457. end;
  458. procedure writehlpindex(filename : string);
  459. var
  460. LS : PFPHTMLFileLinkScanner;
  461. BS : PBufStream;
  462. S : String;
  463. Re : Word;
  464. params : array[0..0] of pointer;
  465. dir : searchrec;
  466. r : trect;
  467. begin
  468. S:='HTML Index';
  469. r.assign(10,10,70,15);
  470. indexdlg:=new(phtmlindexdialog,init(r,'Creating HTML index file, please wait ...'));
  471. desktop^.insert(indexdlg);
  472. New(LS, Init);
  473. LS^.ProcessDocument(FileName,[soSubDocsOnly]);
  474. if LS^.GetDocumentCount=0 then
  475. begin
  476. params[0]:=@filename;
  477. MessageBox('Problem creating help index %1, abording',@params,
  478. mferror+mfyesbutton+mfnobutton);
  479. end
  480. else
  481. begin
  482. FileName:=DirAndNameOf(FileName)+HTMLIndexExt;
  483. findfirst(filename,AnyFile,dir);
  484. if doserror=0 then
  485. begin
  486. params[0]:=@filename;
  487. Re:=MessageBox('Help index %s already exists, overwrite it?',@params,
  488. mfinformation+mfyesbutton+mfnobutton);
  489. end;
  490. if Re<>cmNo then
  491. begin
  492. New(BS, Init(FileName, stCreate, 4096));
  493. if Assigned(BS)=false then
  494. begin
  495. MessageBox('Error while writing help index! '+
  496. 'No help index is created',@params,
  497. mferror+mfokbutton);
  498. Re:=cmCancel;
  499. end
  500. else
  501. begin
  502. LS^.StoreDocuments(BS^);
  503. if BS^.Status<>stOK then
  504. begin
  505. MessageBox('Error while writing help index!'#13+
  506. 'No help index is created',@params,
  507. mferror+mfokbutton);
  508. Re:=cmCancel;
  509. end;
  510. Dispose(BS, Done);
  511. end;
  512. end;
  513. end;
  514. Dispose(LS, Done);
  515. desktop^.delete(indexdlg);
  516. dispose(indexdlg,done);
  517. end;
  518. {*****************************************************************************
  519. Writing of ppc386.cfg
  520. *****************************************************************************}
  521. procedure writedefcfg(const fn:string;const cfgdata : tcfgarray;count : longint);
  522. var
  523. t : text;
  524. i : longint;
  525. s : string;
  526. dir : searchrec;
  527. params : array[0..0] of pointer;
  528. d : dirstr;
  529. n : namestr;
  530. e : extstr;
  531. begin
  532. { already exists }
  533. findfirst(fn,AnyFile,dir);
  534. if doserror=0 then
  535. begin
  536. params[0]:=@fn;
  537. if MessageBox(msg_overwrite_cfg,@params,
  538. mfinformation+mfyesbutton+mfnobutton)=cmNo then
  539. exit;
  540. end;
  541. { create directory }
  542. fsplit(fn,d,n,e);
  543. createdir(d);
  544. { create the ppc386.cfg }
  545. assign(t,fn);
  546. {$I-}
  547. rewrite(t);
  548. {$I+}
  549. if ioresult<>0 then
  550. begin
  551. params[0]:=@fn;
  552. MessageBox(msg_problems_writing_cfg,@params,mfinformation+mfokbutton);
  553. exit;
  554. end;
  555. for i:=1 to count do
  556. if assigned(cfgdata[i]) then
  557. begin
  558. s:=cfgdata[i]^;
  559. Replace(s,'$1',data.basepath);
  560. { error msg file entry? }
  561. if Replace(s,'$L',msgfile) then
  562. begin
  563. { if we've to set an error msg file, we }
  564. { write it else we discard the line }
  565. if msgfile<>'' then
  566. writeln(t,s);
  567. end
  568. else
  569. writeln(t,s);
  570. end
  571. else
  572. writeln(t,'');
  573. close(t);
  574. end;
  575. {*****************************************************************************
  576. TUnZipDialog
  577. *****************************************************************************}
  578. constructor tunzipdialog.Init(var Bounds: TRect; ATitle: TTitleStr);
  579. var
  580. r : trect;
  581. begin
  582. inherited init(bounds,atitle);
  583. (* R.Assign (11, 4, 38, 6);*)
  584. R.Assign (1, 4,bounds.B.X-Bounds.A.X-2, 6);
  585. filetext:=new(pstatictext,init(r,#3'File: '));
  586. insert(filetext);
  587. R.Assign (1, 7,bounds.B.X-Bounds.A.X-2, 9);
  588. extractfiletext:=new(pstatictext,init(r,#3' '));
  589. insert(extractfiletext);
  590. end;
  591. {$IFNDEF DLL}
  592. procedure UnzipCheckFn (Retcode: longint; Rec: pReportRec );{$ifdef Delphi32}STDCALL;{$endif}
  593. {$IFNDEF BIT32} FAR;{$ENDIF BIT32}
  594. var
  595. name : string;
  596. begin
  597. case Rec^.Status of
  598. unzip_starting:
  599. UnzipErr := 0;
  600. file_starting:
  601. begin
  602. with UnzDlg^.extractfiletext^ do
  603. begin
  604. Disposestr(text);
  605. name:=Strpas(Rec^.FileName);
  606. Text:=NewStr(#3+name);
  607. DrawView;
  608. end;
  609. end;
  610. file_failure: UnzipErr := RetCode;
  611. file_unzipping:
  612. begin
  613. with UnzDlg^.FileText^ do
  614. begin
  615. Inc (StatusPos);
  616. if StatusPos > MaxStatusPos then StatusPos := 1;
  617. Text^ [Length (Text^)] := StatusChars [StatusPos];
  618. DrawView;
  619. end;
  620. end;
  621. end;
  622. end;
  623. {$ENDIF}
  624. procedure tunzipdialog.do_unzip(s,topath : string);
  625. var
  626. again : boolean;
  627. fn,dir,wild : string;
  628. Cnt: integer;
  629. params : array[0..0] of pointer;
  630. begin
  631. Disposestr(filetext^.text);
  632. filetext^.Text:=NewStr(#3+str_file+s+ #13#3' ');
  633. filetext^.drawview;
  634. if not(file_exists(s,startpath)) then
  635. begin
  636. params[0]:=@s;
  637. messagebox(msg_file_missing,@params,mferror+mfokbutton);
  638. errorhalt;
  639. end;
  640. {$IFNDEF DLL}
  641. {$IFDEF FPC}
  642. SetUnzipReportProc (@UnzipCheckFn);
  643. {$ELSE FPC}
  644. SetUnzipReportProc (UnzipCheckFn);
  645. {$ENDIF FPC}
  646. {$ENDIF DLL}
  647. repeat
  648. fn:=startpath+DirSep+s+#0;
  649. dir:=topath+#0;
  650. wild:=AllFiles + #0;
  651. again:=false;
  652. FileUnzipEx(@fn[1],@dir[1],@wild[1]);
  653. if (UnzipErr <> 0) then
  654. begin
  655. Str(UnzipErr,s);
  656. params[0]:=@s;
  657. if messagebox(msg_extraction_error,@params,mferror+mfyesbutton+mfnobutton)=cmNo then
  658. errorhalt
  659. else
  660. again:=true;
  661. end;
  662. until not again;
  663. end;
  664. {*****************************************************************************
  665. TEndDialog
  666. *****************************************************************************}
  667. constructor tenddialog.init;
  668. var
  669. R : TRect;
  670. P : PStaticText;
  671. Control : PButton;
  672. YB: word;
  673. {$IFNDEF LINUX}
  674. i : longint;
  675. S: string;
  676. WPath: boolean;
  677. {$ENDIF}
  678. {$IFDEF OS2}
  679. ErrPath: array [0..259] of char;
  680. Handle: longint;
  681. WLibPath: boolean;
  682. const
  683. EMXName: array [1..4] of char = 'EMX'#0;
  684. {$ENDIF}
  685. begin
  686. if haside then
  687. YB := 15
  688. else
  689. YB := 14;
  690. {$IFNDEF LINUX}
  691. s:='';
  692. for i:=1 to cfg.packs do
  693. if cfg.pack[i].binsub<>'' then
  694. begin
  695. if s<>'' then
  696. s:=s+';';
  697. S := s+Data.BasePath + Cfg.pack[i].BinSub;
  698. end;
  699. if Pos (Upper (S), Upper (GetEnv ('PATH'))) = 0 then
  700. begin
  701. WPath := true;
  702. Inc (YB, 2);
  703. end
  704. else
  705. WPath := false;
  706. {$IFDEF OS2}
  707. if DosLoadModule (@ErrPath, SizeOf (ErrPath), @EMXName, Handle) = 0 then
  708. begin
  709. WLibPath := false;
  710. DosFreeModule (Handle);
  711. end
  712. else
  713. begin
  714. WLibPath := true;
  715. Inc (YB, 2);
  716. end;
  717. {$ENDIF}
  718. {$ENDIF}
  719. R.Assign(6, 6, 74, YB);
  720. inherited init(r,dialog_enddialog_title);
  721. {$IFNDEF LINUX}
  722. if WPath then
  723. begin
  724. R.Assign(2, 3, 64, 5);
  725. P:=new(pstatictext,init(r,str_extend_path+''''+S+''''));
  726. insert(P);
  727. end;
  728. {$IFDEF OS2}
  729. if WLibPath then
  730. begin
  731. if WPath then
  732. S := str_libpath+'''' + S + '\'+str_dll+''''
  733. else
  734. S := str_extend_libpath+'''' + S + '\'+str_dll+'''';
  735. R.Assign (2, YB - 14, 64, YB - 12);
  736. P := New (PStaticText, Init (R, S));
  737. Insert (P);
  738. end;
  739. {$ENDIF}
  740. {$ENDIF}
  741. R.Assign(2, YB - 13, 64, YB - 12);
  742. P:=new(pstatictext,init(r,str_to_compile+''''+cfg.pack[1].ppc386+str_file2+''''));
  743. insert(P);
  744. if haside then
  745. begin
  746. R.Assign(2, YB - 12, 64, YB - 10);
  747. P:=new(pstatictext,init(r,str_start_ide));
  748. insert(P);
  749. end;
  750. R.Assign (29, YB - 9, 39, YB - 7);
  751. Control := New (PButton, Init (R,str_ok, cmOK, bfDefault));
  752. Insert (Control);
  753. end;
  754. {*****************************************************************************
  755. TInstallDialog
  756. *****************************************************************************}
  757. var
  758. islfn : boolean;
  759. procedure lfnreport( Retcode : longint;Rec : pReportRec );
  760. {$IFDEF TP}
  761. far;
  762. {$ENDIF}
  763. var
  764. p : pathstr;
  765. n : namestr;
  766. e : extstr;
  767. begin
  768. fsplit(strpas(rec^.Filename),p,n,e);
  769. if length(n)>8 then
  770. islfn:=true;
  771. end;
  772. function haslfn(const zipfile,path : string) : boolean;
  773. var
  774. buf : array[0..255] of char;
  775. begin
  776. strpcopy(buf,path+DirSep+zipfile);
  777. islfn:=false;
  778. {$ifdef FPC}
  779. ViewZip(buf,AllFiles,@lfnreport);
  780. {$else FPC}
  781. ViewZip(buf,AllFiles,lfnreport);
  782. {$endif FPC}
  783. haslfn:=islfn;
  784. end;
  785. constructor tlanguagedialog.init;
  786. const
  787. languages = 8;
  788. width = 40;
  789. height = languages+6;
  790. x1 = (79-width) div 2;
  791. y1 = (23-height) div 2;
  792. x2 = x1+width;
  793. y2 = y1+height;
  794. var
  795. r : trect;
  796. okbut : pbutton;
  797. line : longint;
  798. rb : PRadioButtons;
  799. begin
  800. r.assign(x1,y1,x2,y2);
  801. inherited init(r,dialog_language_title);
  802. GetExtent(R);
  803. R.Grow(-2,-1);
  804. line:=r.a.y+1;
  805. r.assign((width div 2)-15,line,(width div 2)+15,line+languages);
  806. New(rb, Init(r,
  807. NewSItem(dialog_language_english,
  808. NewSItem(dialog_language_dutch,
  809. NewSItem(dialog_language_french,
  810. NewSItem(dialog_language_russian,
  811. NewSItem(dialog_language_hungarian,
  812. NewSItem(dialog_language_spanish,
  813. NewSItem(dialog_language_german,
  814. NewSItem(dialog_language_russian_win,
  815. nil))))))))));
  816. insert(rb);
  817. inc(line,languages);
  818. inc(line,1);
  819. r.assign((width div 2)-5,line,(width div 2)+5,line+2);
  820. new(okbut,init(r,str_ok,cmok,bfdefault));
  821. Insert(OkBut);
  822. end;
  823. constructor tinstalldialog.init;
  824. const
  825. width = 76;
  826. height = 20;
  827. x1 = (79-width) div 2;
  828. y1 = (23-height) div 2;
  829. x2 = x1+width;
  830. y2 = y1+height;
  831. var
  832. tabr,tabir,r : trect;
  833. packmask : array[1..maxpacks] of longint;
  834. i,line,j : integer;
  835. items : array[1..maxpacks] of psitem;
  836. f : pview;
  837. found : boolean;
  838. okbut,cancelbut : pbutton;
  839. firstitem : array[1..maxpacks] of integer;
  840. packcbs : array[1..maxpacks] of pcheckboxes;
  841. packtd : ptabdef;
  842. labpath : plabel;
  843. ilpath : pinputline;
  844. tab : ptab;
  845. titletext : pcoloredtext;
  846. labcfg : plabel;
  847. cfgcb : pcheckboxes;
  848. scrollbox: pscrollbox;
  849. sbr,sbsbr: trect;
  850. sbsb: pscrollbar;
  851. begin
  852. f:=nil;
  853. { walk packages reverse and insert a newsitem for each, and set the mask }
  854. for j:=1 to cfg.packs do
  855. with cfg.pack[j] do
  856. begin
  857. firstitem[j]:=0;
  858. items[j]:=nil;
  859. packmask[j]:=0;
  860. for i:=packages downto 1 do
  861. begin
  862. if file_exists(package[i].zip,startpath) then
  863. begin
  864. {$ifdef go32v2}
  865. if not(lfnsupport) then
  866. begin
  867. if not(haslfn(package[i].zip,startpath)) then
  868. begin
  869. items[j]:=newsitem(package[i].name+diskspace(startpath+DirSep+package[i].zip),items[j]);
  870. packmask[j]:=packmask[j] or packagemask(i);
  871. firstitem[j]:=i;
  872. if createlog then
  873. writeln(log,str_checking_lfn,startpath+DirSep+package[i].zip,' ... no lfn');
  874. end
  875. else
  876. begin
  877. items[j]:=newsitem(package[i].name+str_requires_lfn,items[j]);
  878. if createlog then
  879. writeln(log,str_checking_lfn,startpath+DirSep+package[i].zip,' ... uses lfn');
  880. end;
  881. end
  882. else
  883. {$endif go32v2}
  884. begin
  885. items[j]:=newsitem(package[i].name+diskspace(startpath+DirSep+package[i].zip),items[j]);
  886. packmask[j]:=packmask[j] or packagemask(i);
  887. firstitem[j]:=i;
  888. end;
  889. end
  890. else
  891. items[j]:=newsitem(package[i].name,items[j]);
  892. end;
  893. end;
  894. { If no component found abort }
  895. found:=false;
  896. for j:=1 to cfg.packs do
  897. if packmask[j]<>0 then
  898. found:=true;
  899. if not found then
  900. begin
  901. messagebox(msg_no_components_found,nil,mferror+mfokbutton);
  902. errorhalt;
  903. end;
  904. r.assign(x1,y1,x2,y2);
  905. inherited init(r,'');
  906. GetExtent(R);
  907. R.Grow(-2,-1);
  908. Dec(R.B.Y,2);
  909. TabR.Copy(R);
  910. TabIR.Copy(R);
  911. TabIR.Grow(-2,-2);
  912. TabIR.Move(-2,0);
  913. {-------- General Sheets ----------}
  914. R.Copy(TabIR);
  915. r.move(0,1);
  916. r.b.x:=r.a.x+40;
  917. r.b.y:=r.a.y+1;
  918. new(titletext,init(r,cfg.title,$71));
  919. r.move(0,2);
  920. r.b.x:=r.a.x+40;
  921. new(labpath,init(r,dialog_install_basepath,f));
  922. r.move(0,1);
  923. r.b.x:=r.a.x+40;
  924. r.b.y:=r.a.y+1;
  925. new(ilpath,init(r,high(DirStr)));
  926. r.move(0,2);
  927. r.b.x:=r.a.x+40;
  928. new(labcfg,init(r,dialog_install_config,f));
  929. r.move(0,1);
  930. r.b.x:=r.a.x+40;
  931. r.b.y:=r.a.y+1;
  932. new(cfgcb,init(r,newsitem(dialog_install_createppc386cfg,nil)));
  933. data.cfgval:=1;
  934. {-------- Pack Sheets ----------}
  935. for j:=1 to cfg.packs do
  936. begin
  937. R.Copy(TabIR);
  938. if R.A.Y+cfg.pack[j].packages>R.B.Y then
  939. R.B.Y:=R.A.Y+cfg.pack[j].packages;
  940. new(packcbs[j],init(r,items[j]));
  941. if data.packmask[j]=$ffff then
  942. data.packmask[j]:=packmask[j];
  943. packcbs[j]^.enablemask:={$ifdef DEV}$7fffffff{$else}packmask[j]{$endif};
  944. packcbs[j]^.movedto(firstitem[j]);
  945. end;
  946. {--------- Main ---------}
  947. packtd:=nil;
  948. sbr.assign(1,3,tabr.b.x-tabr.a.x-3,tabr.b.y-tabr.a.y-1);
  949. for j:=cfg.packs downto 1 do
  950. begin
  951. if (sbr.b.y-sbr.a.y)<cfg.pack[j].packages then
  952. begin
  953. sbsbr.assign(sbr.b.x,sbr.a.y,sbr.b.x+1,sbr.b.y);
  954. New(sbsb, init(sbsbr));
  955. end
  956. else
  957. sbsb:=nil;
  958. New(ScrollBox, Init(sbr, nil, sbsb));
  959. PackCbs[j]^.MoveTo(0,0);
  960. ScrollBox^.Insert(PackCbs[j]);
  961. packtd:=NewTabDef(
  962. cfg.pack[j].name,ScrollBox,
  963. NewTabItem(sbsb,
  964. NewTabItem(ScrollBox,
  965. nil)),
  966. packtd);
  967. end;
  968. New(Tab, Init(TabR,
  969. NewTabDef(dialog_install_general,IlPath,
  970. NewTabItem(TitleText,
  971. NewTabItem(LabPath,
  972. NewTabItem(ILPath,
  973. NewTabItem(LabCfg,
  974. NewTabItem(CfgCB,
  975. nil))))),
  976. packtd)
  977. ));
  978. Tab^.GrowMode:=0;
  979. Insert(Tab);
  980. line:=tabr.b.y;
  981. r.assign((width div 2)-18,line,(width div 2)-4,line+2);
  982. new(okbut,init(r,str_continue,cmok,bfdefault));
  983. Insert(OkBut);
  984. r.assign((width div 2)+4,line,(width div 2)+14,line+2);
  985. new(cancelbut,init(r,str_quit,cmcancel,bfnormal));
  986. Insert(CancelBut);
  987. Tab^.Select;
  988. end;
  989. {*****************************************************************************
  990. TUnZipDialog
  991. *****************************************************************************}
  992. procedure tapp.do_languagedialog;
  993. var
  994. p : planguagedialog;
  995. langdata : longint;
  996. c : word;
  997. begin
  998. { select components }
  999. new(p,init);
  1000. langdata:=0;
  1001. c:=executedialog(p,@langdata);
  1002. writeln(langdata);
  1003. if c=cmok then
  1004. begin
  1005. case langdata of
  1006. 0:
  1007. cfg.language:='English';
  1008. 1:
  1009. begin
  1010. cfg.language:='Dutch';
  1011. msgfile:='errorn.msg';
  1012. end;
  1013. 2:
  1014. begin
  1015. cfg.language:='French';
  1016. msgfile:='errorf.msg';
  1017. end;
  1018. 3:
  1019. begin
  1020. cfg.language:='Russian';
  1021. msgfile:='errorr.msg';
  1022. end;
  1023. 4:
  1024. cfg.language:='Hungarian';
  1025. 5:
  1026. begin
  1027. cfg.language:='Spanish';
  1028. msgfile:='errors.msg';
  1029. end;
  1030. 6:
  1031. begin
  1032. cfg.language:='German';
  1033. msgfile:='errord.msg';
  1034. end;
  1035. 7:
  1036. begin
  1037. cfg.language:='RussianWin';
  1038. msgfile:='errorrw.msg';
  1039. end;
  1040. end;
  1041. end;
  1042. end;
  1043. {*****************************************************************************
  1044. TApp
  1045. *****************************************************************************}
  1046. const
  1047. cmstart = 1000;
  1048. procedure tapp.do_installdialog;
  1049. var
  1050. p : pinstalldialog;
  1051. p3 : penddialog;
  1052. r : trect;
  1053. result,
  1054. c : word;
  1055. i,j : longint;
  1056. found : boolean;
  1057. params : array[0..0] of pointer;
  1058. {$ifndef linux}
  1059. DSize,Space,ASpace : longint;
  1060. S: DirStr;
  1061. {$endif}
  1062. procedure doconfigwrite;
  1063. var
  1064. i : longint;
  1065. begin
  1066. for i:=1 to cfg.packs do
  1067. if cfg.pack[i].defcfgfile<>'' then
  1068. writedefcfg(data.basepath+cfg.pack[i].binsub+DirSep+cfg.pack[i].defcfgfile,cfg.defcfg,cfg.defcfgs);
  1069. if haside then
  1070. begin
  1071. for i:=1 to cfg.packs do
  1072. if cfg.pack[i].defidecfgfile<>'' then
  1073. writedefcfg(data.basepath+cfg.pack[i].binsub+DirSep+cfg.pack[i].defidecfgfile,cfg.defidecfg,cfg.defidecfgs);
  1074. for i:=1 to cfg.packs do
  1075. if cfg.pack[i].defideinifile<>'' then
  1076. writedefcfg(data.basepath+cfg.pack[i].binsub+DirSep+cfg.pack[i].defideinifile,cfg.defideini,cfg.defideinis);
  1077. if hashtmlhelp then
  1078. writehlpindex(data.basepath+DirSep+cfg.DocSub+DirSep+cfg.helpidx);
  1079. end;
  1080. end;
  1081. begin
  1082. data.basepath:=cfg.basepath;
  1083. data.cfgval:=0;
  1084. for j:=1 to cfg.packs do
  1085. data.packmask[j]:=$ffff;
  1086. repeat
  1087. { select components }
  1088. p:=new(pinstalldialog,init);
  1089. c:=executedialog(p,@data);
  1090. if (c=cmok) then
  1091. begin
  1092. if Data.BasePath = '' then
  1093. messagebox(msg_select_dir,nil,mferror+mfokbutton)
  1094. else
  1095. begin
  1096. found:=false;
  1097. for j:=1 to cfg.packs do
  1098. if data.packmask[j]>0 then
  1099. found:=true;
  1100. if found then
  1101. begin
  1102. {$IFNDEF LINUX}
  1103. { TH - check the available disk space here }
  1104. DSize := 0;
  1105. for j:=1 to cfg.packs do
  1106. with cfg.pack[j] do
  1107. begin
  1108. for i:=1 to packages do
  1109. begin
  1110. if data.packmask[j] and packagemask(i)<>0 then
  1111. begin
  1112. ASpace := DiskSpaceN (package[i].zip);
  1113. if ASpace = -1 then
  1114. begin
  1115. params[0]:=@package[i].zip;
  1116. MessageBox (msg_corrupt_zip,
  1117. @params,mferror + mfokbutton);
  1118. end
  1119. else Inc (DSize, ASpace);
  1120. end;
  1121. end;
  1122. end;
  1123. S := FExpand (Data.BasePath);
  1124. if S [Length (S)] = DirSep then
  1125. Dec (S [0]);
  1126. Space := DiskFree (byte (Upcase(S [1])) - 64) shr 10;
  1127. if Space < DSize then
  1128. S := str_is_not
  1129. else
  1130. S := '';
  1131. if (Space < DSize + 500) then
  1132. begin
  1133. if S = '' then
  1134. S := str_might_not_be;
  1135. params[0]:=@s;
  1136. if messagebox(msg_space_warning,@params,
  1137. mferror+mfyesbutton+mfnobutton) = cmYes then
  1138. Continue;
  1139. end;
  1140. {$ENDIF}
  1141. if createinstalldir(data.basepath) then
  1142. break;
  1143. end
  1144. else
  1145. begin
  1146. { maybe only config }
  1147. if (data.cfgval and 1)<>0 then
  1148. begin
  1149. result:=messagebox(msg_no_components_selected,nil,
  1150. mfinformation+mfyesbutton+mfnobutton);
  1151. if (result=cmYes) and createinstalldir(data.basepath) then
  1152. doconfigwrite;
  1153. exit;
  1154. end
  1155. else
  1156. begin
  1157. result:=messagebox(msg_nocomponents,nil,
  1158. mferror+mfyesbutton+mfnobutton);
  1159. if result=cmYes then
  1160. exit;
  1161. end;
  1162. end;
  1163. end;
  1164. end
  1165. else
  1166. exit;
  1167. until false;
  1168. { extract packages }
  1169. for j:=1 to cfg.packs do
  1170. with cfg.pack[j] do
  1171. begin
  1172. r.assign(10,7,70,18);
  1173. UnzDlg:=new(punzipdialog,init(r,dialog_unzipdialog_title));
  1174. desktop^.insert(UnzDlg);
  1175. for i:=1 to packages do
  1176. begin
  1177. if data.packmask[j] and packagemask(i)<>0 then
  1178. UnzDlg^.do_unzip(package[i].zip,data.basepath);
  1179. end;
  1180. desktop^.delete(UnzDlg);
  1181. dispose(UnzDlg,done);
  1182. end;
  1183. { write config }
  1184. if (data.cfgval and 1)<>0 then
  1185. doconfigwrite;
  1186. { show end message }
  1187. p3:=new(penddialog,init);
  1188. executedialog(p3,nil);
  1189. end;
  1190. procedure tapp.readcfg(const fn:string);
  1191. var
  1192. t : text;
  1193. i,j,
  1194. line : longint;
  1195. item,
  1196. s : string;
  1197. params : array[0..0] of pointer;
  1198. {$ifndef FPC}
  1199. procedure readln(var t:text;var s:string);
  1200. var
  1201. c : char;
  1202. i : longint;
  1203. begin
  1204. c:=#0;
  1205. i:=0;
  1206. while (not eof(t)) and (c<>#10) do
  1207. begin
  1208. read(t,c);
  1209. if c<>#10 then
  1210. begin
  1211. inc(i);
  1212. s[i]:=c;
  1213. end;
  1214. end;
  1215. if (i>0) and (s[i]=#13) then
  1216. dec(i);
  1217. s[0]:=chr(i);
  1218. end;
  1219. {$endif}
  1220. begin
  1221. assign(t,StartPath + DirSep + fn);
  1222. {$I-}
  1223. reset(t);
  1224. {$I+}
  1225. if ioresult<>0 then
  1226. begin
  1227. StartPath := GetProgDir;
  1228. assign(t,StartPath + DirSep + fn);
  1229. {$I-}
  1230. reset(t);
  1231. {$I+}
  1232. if ioresult<>0 then
  1233. begin
  1234. params[0]:=@fn;
  1235. messagebox(msg_file_not_found,@params,mferror+mfokbutton);
  1236. errorhalt;
  1237. end;
  1238. end;
  1239. line:=0;
  1240. while not eof(t) do
  1241. begin
  1242. readln(t,s);
  1243. inc(line);
  1244. if (s<>'') and not(s[1] in ['#',';']) then
  1245. begin
  1246. i:=pos('=',s);
  1247. if i>0 then
  1248. begin
  1249. item:=upper(Copy(s,1,i-1));
  1250. system.delete(s,1,i);
  1251. if item='VERSION' then
  1252. cfg.version:=s
  1253. else
  1254. if item='TITLE' then
  1255. cfg.title:=s
  1256. else
  1257. if item='LANGUAGE' then
  1258. cfg.language:=s
  1259. else
  1260. if item='BASEPATH' then
  1261. cfg.basepath:=s
  1262. else
  1263. if item='HELPIDX' then
  1264. cfg.helpidx:=s
  1265. else
  1266. if item='DOCSUB' then
  1267. cfg.docsub:=s
  1268. else
  1269. if item='DEFAULTCFG' then
  1270. begin
  1271. repeat
  1272. readln(t,s);
  1273. if upper(s)='ENDCFG' then
  1274. break;
  1275. if cfg.defcfgs<maxdefcfgs then
  1276. begin
  1277. inc(cfg.defcfgs);
  1278. cfg.defcfg[cfg.defcfgs]:=newstr(s);
  1279. end;
  1280. until false;
  1281. end
  1282. else if item='DEFAULTIDECFG' then
  1283. begin
  1284. repeat
  1285. readln(t,s);
  1286. if upper(s)='ENDCFG' then
  1287. break;
  1288. if cfg.defidecfgs<maxdefcfgs then
  1289. begin
  1290. inc(cfg.defidecfgs);
  1291. cfg.defidecfg[cfg.defidecfgs]:=newstr(s);
  1292. end;
  1293. until false;
  1294. end
  1295. else if item='DEFAULTIDEINI' then
  1296. begin
  1297. repeat
  1298. readln(t,s);
  1299. if upper(s)='ENDCFG' then
  1300. break;
  1301. if cfg.defideinis<maxdefcfgs then
  1302. begin
  1303. inc(cfg.defideinis);
  1304. cfg.defideini[cfg.defideinis]:=newstr(s);
  1305. end;
  1306. until false;
  1307. end
  1308. else
  1309. if item='PACK' then
  1310. begin
  1311. inc(cfg.packs);
  1312. if cfg.packs>maxpacks then
  1313. begin
  1314. writeln('Too much packs');
  1315. halt(1);
  1316. end;
  1317. cfg.pack[cfg.packs].name:=s;
  1318. end
  1319. else
  1320. if item='CFGFILE' then
  1321. begin
  1322. if cfg.packs=0 then
  1323. begin
  1324. writeln('No pack set');
  1325. halt(1);
  1326. end;
  1327. cfg.pack[cfg.packs].defcfgfile:=s
  1328. end
  1329. else
  1330. if item='IDECFGFILE' then
  1331. begin
  1332. if cfg.packs=0 then
  1333. begin
  1334. writeln('No pack set');
  1335. halt(1);
  1336. end;
  1337. cfg.pack[cfg.packs].defidecfgfile:=s
  1338. end
  1339. else
  1340. if item='IDEINIFILE' then
  1341. begin
  1342. if cfg.packs=0 then
  1343. begin
  1344. writeln('No pack set');
  1345. halt(1);
  1346. end;
  1347. cfg.pack[cfg.packs].defideinifile:=s
  1348. end
  1349. else
  1350. if item='PPC386' then
  1351. begin
  1352. if cfg.packs=0 then
  1353. begin
  1354. writeln('No pack set');
  1355. halt(1);
  1356. end;
  1357. cfg.pack[cfg.packs].ppc386:=s;
  1358. end
  1359. else
  1360. if item='BINSUB' then
  1361. begin
  1362. if cfg.packs=0 then
  1363. begin
  1364. writeln('No pack set');
  1365. halt(1);
  1366. end;
  1367. cfg.pack[cfg.packs].binsub:=s;
  1368. end
  1369. else
  1370. if item='FILECHECK' then
  1371. begin
  1372. if cfg.packs=0 then
  1373. begin
  1374. writeln('No pack set');
  1375. halt(1);
  1376. end;
  1377. cfg.pack[cfg.packs].filechk:=s;
  1378. end
  1379. else
  1380. if item='PACKAGE' then
  1381. begin
  1382. if cfg.packs=0 then
  1383. begin
  1384. writeln('No pack set');
  1385. halt(1);
  1386. end;
  1387. if copy(s,1,3)='ide' then
  1388. haside:=true;
  1389. if copy(s,1,7)='doc-htm' then
  1390. hashtmlhelp:=true;
  1391. with cfg.pack[cfg.packs] do
  1392. begin
  1393. j:=pos(',',s);
  1394. if (j>0) and (packages<maxpackages) then
  1395. begin
  1396. inc(packages);
  1397. package[packages].zip:=copy(s,1,j-1);
  1398. package[packages].name:=copy(s,j+1,255);
  1399. end;
  1400. end;
  1401. end
  1402. end;
  1403. end;
  1404. end;
  1405. close(t);
  1406. end;
  1407. procedure tapp.checkavailpack;
  1408. var
  1409. j : longint;
  1410. dir : searchrec;
  1411. begin
  1412. { check the packages }
  1413. j:=0;
  1414. while (j<cfg.packs) do
  1415. begin
  1416. inc(j);
  1417. if cfg.pack[j].filechk<>'' then
  1418. begin
  1419. findfirst(cfg.pack[j].filechk,$20,dir);
  1420. if doserror<>0 then
  1421. begin
  1422. { remove the package }
  1423. move(cfg.pack[j+1],cfg.pack[j],sizeof(tpack)*(cfg.packs-j));
  1424. dec(cfg.packs);
  1425. dec(j);
  1426. end;
  1427. {$IFNDEF TP}
  1428. findclose(dir);
  1429. {$ENDIF}
  1430. end;
  1431. end;
  1432. end;
  1433. procedure tapp.initmenubar;
  1434. var
  1435. r : trect;
  1436. begin
  1437. getextent(r);
  1438. r.b.y:=r.a.y+1;
  1439. menubar:=new(pmenubar,init(r,newmenu(
  1440. newsubmenu(menu_install,hcnocontext,newmenu(nil
  1441. ),
  1442. nil))));
  1443. end;
  1444. procedure tapp.handleevent(var event : tevent);
  1445. begin
  1446. inherited handleevent(event);
  1447. if event.what=evcommand then
  1448. if event.command=cmstart then
  1449. begin
  1450. clearevent(event);
  1451. do_installdialog;
  1452. if successfull then
  1453. begin
  1454. event.what:=evcommand;
  1455. event.command:=cmquit;
  1456. handleevent(event);
  1457. end;
  1458. end;
  1459. end;
  1460. {$IFDEF DOSSTUB}
  1461. function CheckOS2: boolean;
  1462. var
  1463. OwnName: PathStr;
  1464. OwnDir: DirStr;
  1465. Name: NameStr;
  1466. Ext: ExtStr;
  1467. DosV, W: word;
  1468. P: PChar;
  1469. const
  1470. Title: string [15] = 'FPC Installer'#0;
  1471. RunBlock: TRunBlock = (Length: $32;
  1472. Dependent: 0;
  1473. Background: 0;
  1474. TraceLevel: 0;
  1475. PrgTitle: @Title [1];
  1476. PrgName: nil;
  1477. Args: nil;
  1478. TermQ: 0;
  1479. Environment: nil;
  1480. Inheritance: 0;
  1481. SesType: 2;
  1482. Icon: nil;
  1483. PgmHandle: 0;
  1484. PgmControl: 2;
  1485. Column: 0;
  1486. Row: 0;
  1487. Width: 80;
  1488. Height: 25);
  1489. begin
  1490. CheckOS2 := false;
  1491. asm
  1492. mov ah, 30h
  1493. int 21h
  1494. xchg ah, al
  1495. mov DosV, ax
  1496. mov ax, 4010h
  1497. int 2Fh
  1498. cmp ax, 4010h
  1499. jnz @0
  1500. xor bx, bx
  1501. @0:
  1502. mov W, bx
  1503. end;
  1504. if DosV > 3 shl 8 then
  1505. begin
  1506. OwnName := FExpand (ParamStr (0));
  1507. FSplit (OwnName, OwnDir, Name, Ext);
  1508. if (DosV >= 20 shl 8 + 10) and (W >= 20 shl 8 + 10) then
  1509. (* OS/2 version 2.1 or later running (double-checked) *)
  1510. begin
  1511. OwnName [Succ (byte (OwnName [0]))] := #0;
  1512. RunBlock.PrgName := @OwnName [1];
  1513. P := Ptr (PrefixSeg, $80);
  1514. if PByte (P)^ <> 0 then
  1515. begin
  1516. Inc (P);
  1517. RunBlock.Args := Ptr (PrefixSeg, $81);
  1518. end;
  1519. asm
  1520. mov ax, 6400h
  1521. mov bx, 0025h
  1522. mov cx, 636Ch
  1523. mov si, offset RunBlock
  1524. int 21h
  1525. jc @0
  1526. mov DosV, 0
  1527. @0:
  1528. end;
  1529. CheckOS2 := DosV = 0;
  1530. end;
  1531. end;
  1532. end;
  1533. {$ENDIF}
  1534. var
  1535. i : longint;
  1536. begin
  1537. { register objects for help streaming }
  1538. RegisterWHTMLScan;
  1539. {$ifdef FPC}
  1540. {$ifdef win32}
  1541. Dos.Exec(GetEnv('COMSPEC'),'/C echo This dummy call gets the mouse to become visible');
  1542. {$endif win32}
  1543. {$endif FPC}
  1544. (* TH - no error boxes if checking an inaccessible disk etc. *)
  1545. {$IFDEF OS2}
  1546. {$IFDEF FPC}
  1547. DosCalls.DosError (0);
  1548. {$ELSE FPC}
  1549. {$IFDEF VirtualPascal}
  1550. OS2Base.DosError (ferr_DisableHardErr);
  1551. {$ELSE VirtualPascal}
  1552. BseDos.DosError (0);
  1553. {$ENDIF VirtualPascal}
  1554. {$ENDIF FPC}
  1555. {$ENDIF}
  1556. {$IFDEF DOSSTUB}
  1557. if CheckOS2 then Halt;
  1558. {$ENDIF}
  1559. createlog:=false;
  1560. for i:=1 to paramcount do
  1561. begin
  1562. if paramstr(i)='-l' then
  1563. createlog:=true
  1564. else if paramstr(i)='-h' then
  1565. begin
  1566. writeln('FPC Installer Copyright (c) 1993-2000 Florian Klaempfl');
  1567. writeln('Command line options:');
  1568. writeln(' -l create log file');
  1569. writeln;
  1570. writeln(' -h displays this help');
  1571. halt(0);
  1572. end
  1573. else
  1574. begin
  1575. writeln('Illegal command line parameter: ',paramstr(i));
  1576. halt(1);
  1577. end;
  1578. end;
  1579. if createlog then
  1580. begin
  1581. assign(log,'install.log');
  1582. rewrite(log);
  1583. if not(lfnsupport) then
  1584. writeln(log,'OS doesn''t have LFN support');
  1585. end;
  1586. getdir(0,startpath);
  1587. successfull:=false;
  1588. fillchar(cfg, SizeOf(cfg), 0);
  1589. fillchar(data, SizeOf(data), 0);
  1590. { set a default language }
  1591. cfg.language:='English';
  1592. { don't use a message file by default }
  1593. msgfile:='';
  1594. installapp.init;
  1595. FSplit (FExpand (ParamStr (0)), DStr, CfgName, EStr);
  1596. installapp.readcfg(CfgName + CfgExt);
  1597. installapp.checkavailpack;
  1598. installapp.do_languagedialog;
  1599. { installapp.readcfg(startpath+dirsep+cfgfile);}
  1600. if not(lfnsupport) then
  1601. MessageBox(msg_no_lfn,nil,mfinformation or mfokbutton);
  1602. installapp.do_installdialog;
  1603. installapp.done;
  1604. if createlog then
  1605. close(log);
  1606. end.
  1607. {
  1608. $Log$
  1609. Revision 1.10 2000-10-11 15:57:47 peter
  1610. * merged ide additions
  1611. Revision 1.9 2000/10/08 18:43:17 hajny
  1612. * the language dialog repaired
  1613. Revision 1.8 2000/09/24 10:52:36 peter
  1614. * smaller window
  1615. Revision 1.7 2000/09/22 23:13:37 pierre
  1616. * add emulation for go32v2 and display currently extraced file
  1617. and changes by Gabor for scrolling support (merged)
  1618. Revision 1.6 2000/09/22 12:15:49 florian
  1619. + support of Russian (Windows)
  1620. Revision 1.5 2000/09/22 11:07:51 florian
  1621. + all language dependend strings are now resource strings
  1622. + the -Fr switch is now set in the ppc386.cfg
  1623. Revision 1.4 2000/09/21 22:09:23 florian
  1624. + start of multilanguage support
  1625. Revision 1.3 2000/09/17 14:44:12 hajny
  1626. * compilable with TP again
  1627. Revision 1.2 2000/07/21 10:43:01 florian
  1628. + added for lfn support
  1629. Revision 1.1 2000/07/13 06:30:21 michael
  1630. + Initial import
  1631. }