/* applet package - Apr 99 - Sylvain Huet */ /* main function should be called with : - main "url" "size" this first file is strextr format : - several lines with : url name size type sgn url should start with either http:// or ftp:// type is 1 if munzip must be applied to the document, else type is 0 size is only used for the progress bar - then the word 'script' followed by the starting script (with \ before spaces into strings) - any line before 'script' that does not start with http://... or ftp://... is considered as comment Example : # comment http://1.2.3.4/a.pkg test/a.pkg 123 0 _ http://5.6.7.8/b.pkg test/b.pkg 456 0 _ # another comment script _load "test/a.pkg" _load "test/b.pkg" main */ typeof ch=Chn;; fun getInfo(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmp hd q a then hd tl q else getInfo nxt a;; fun _end(a,b,r)=_closemachine;; /* graphic interface */ typeof sizetoload=I;; fun _endApplet()= _DLGrflmessage _DLGMessageBox _channel win loc "ERROR" loc "ERRAPP" 0 @_end 0; 0;; fun _paintevent(a,b)= _BLTbitmap win barre 5 75;0;; fun _destroyevent(a,b)=_closemachine;; fun startWin(txt)= _SETtext message txt;; fun setSize(i)=set sizetoload=if i>0 then i else 1;; fun drawBarre(i)= let _GETbitmapSize barre -> [bw bh] in _DRAWrectangle barre 5 5 min (bw-1) (bw-1)*i/sizetoload 10 DRAW_INVISIBLE 0 0 DRAW_SOLID 0xff0000; _paintevent nil nil;; /* download */ var Flag_munzip=1;; var Flag_unzip=2;; typeof curtext=S;; fun newurl(url)= if strcmpi _getress "Firewall" "strong" then url else let 2+strfind "//" url 0 -> i in if i==nil then url else let strfind "/" url i -> j in let if j==nil then [url nil] else [substr url 0 j substr url j strlen url] ->[pref suff] in let strfind ":" pref i -> k in strcat (if k==nil then pref else strcat strcat substr pref 0 k ":" _getress "FirewallPort") suff;; fun cb(inet,z,s,reason)= if reason==0 then (set curtext=strcat curtext s; drawBarre strlen curtext) else if reason==1 then (set curtext=strcat curtext s; drawBarre strlen curtext; let z->[f type sgn name] in let if type&Flag_munzip then munzip curtext else if type&Flag_unzip then unzip curtext else curtext -> cont in if (sgn!=nil)&&(strlen sgn)&& strcmp sgn _getlongname cont "" "#" then exec f with [nil] else if name==nil then exec f with [cont] else (_storepack cont name; exec f with [name]) ) else let z->[f _ _ _] in exec f with [nil];; fun getUrl(url,f,type,sgn,name,size)= startWin strloc loc "DOWNL" name::(itoa (size>>10))::nil; setSize size; drawBarre 0; set curtext=""; let INETGetURL ch newurl url 0 @cb [f type sgn name] -> url in if url==nil then exec f with [nil] else 0;; fun chkPkg(url,f,type,sgn,name,size)= let _getpack _checkpack name -> cont in if !strcmp _getlongname cont "" "#" sgn then exec f with [name] else getUrl url f type sgn name size;; proto applyApplet=fun [[[S r1]r1]] I;; fun getApplet2(s,l)= if s==nil then _endApplet else applyApplet l;; fun applyApplet(l)= if l==nil then _endApplet else let l->[a n] in let a->[url [name[size[type[sgn _]]]]] in if url==nil then applyApplet n else if (!strcmp "http://" substr url 0 7) || (!strcmp "https://" substr url 0 8) || (!strcmp "ftp://" substr url 0 6) then chkPkg url (mknode @getApplet2 n) atoi type sgn name atoi size else if !strcmp "script" url then ( _DSwindow win; _DSwindow winAX; _DSbitmap barre; // _killchannel screen; _setrights rights; _setenv _channel nil; _script strbuild n; 0; ) else if !strcmp "versionmin" url then if _version l in applyApplet l;; fun main(url,size)= /* _showconsole;*/ _cacheActivate; set ch=_channel; chkPkg url @getApplet 0 "" nil atoi size;;