fun btime(itime) = let ctime itime -> ftime in let substr ftime 4 3 -> mois in let substr ftime 8 2 -> num in let substr ftime 20 4 -> an in ( //TRADUCTION DES MOIS// let "Jan"::"Feb"::"Mar"::"Apr"::"May"::"Jun"::"Jul"::"Aug"::"Sep"::"Oct"::"Nov"::"Dec"::nil -> emois in let "01"::"02"::"03"::"04"::"05"::"06"::"07"::"08"::"09"::"10"::"11"::"12"::nil -> fmois in let 0 -> ok in let 0 -> ct in ( while (ok==0) do ( if (!strcmp mois nth_list emois ct) then ( set mois = nth_list fmois ct; set ok = 1; ) else set ct = ct+1; ); ); strcatn num::"/"::mois::"/"::an::nil );; /*********************************************************************************** * Retourne une date au format "jour/mois/an heure:min:sec" * * -> time : I //Nombre de secondes écoulées depuis le 1er janvier 1970 * * <- chaine : S //la date formatée * **********************************************************************************/ fun dtime(ttime)= let ctime ttime -> ftime in let substr ftime 4 3 -> mois in let substr ftime 8 2 -> num in let substr ftime 20 4 -> an in let substr ftime 11 2 -> heure in let substr ftime 14 2 -> min in let substr ftime 17 2 -> sec in ( //TRADUCTION DES MOIS// let "Jan"::"Feb"::"Mar"::"Apr"::"May"::"Jun"::"Jul"::"Aug"::"Sep"::"Oct"::"Nov"::"Dec"::nil -> emois in let "01"::"02"::"03"::"04"::"05"::"06"::"07"::"08"::"09"::"10"::"11"::"12"::nil -> fmois in let 0 -> ok in let 0 -> ct in ( while (ok==0) do ( if (!strcmp mois nth_list emois ct) then ( set mois = nth_list fmois ct; set ok = 1; ) else set ct = ct+1; ); ); strcatn num::"/"::mois::"/"::an::" "::heure::":"::min::":"::sec::nil; );; fun cutlist(l,n,s)= if l==nil || n==0 then nil else let l-> [a nxt] in if !strcmp a s then cutlist nxt n s else [a cutlist nxt n-1 s];; fun getlibname(env)= if env==nil then nil else ((_envfirstname env)::nil)::getlibname _removepkg env;; fun multiress(res)= if res == nil then 0 else let res ->[[l n] nxt] in ( if strcmp l "#" then _setress l hd n else nil; multiress nxt );; fun getInfos(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmp hd q a then tl q else getInfos nxt a;; 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 getInfoI(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmpi hd q a then hd tl q else getInfoI nxt a;; fun chgress2(l,a,b,s,k)= if l==nil then if k then s::nil else nil else let l->[ll n] in let hd hd strextr ll -> h in if h==nil || strcmp h a then ll::chgress2 n a b s k else if b==nil || k==0 then chgress2 n a b s 0 else s::chgress2 n a b s 0;; fun chgress(a,b)= let lineextr _loadressini -> l in let strbuild (a::b::nil)::nil -> s in _saveressini linebuild chgress2 l a b substr s 0 (strlen s)-1 1; if b==nil then _setress a nil else nil; multiress strextr _loadressini;; typeof lCurrentDl = [[S INET] r1];; fun remove_sid_from_list(l, sid)= if l==nil then nil else let hd l -> [id _] in if (!strcmpi id sid) then tl l else (hd l)::remove_sid_from_list tl l sid;; fun stopUrlDownload(url)= let switchstri lCurrentDl url -> ninet in INETStopURL ninet; set lCurrentDl = remove_sid_from_list lCurrentDl url; 0;; fun cbGetPostUrl(req, params, data, code) = let params -> [url cbfun cberror str] in ( let switchstri lCurrentDl url -> ninet in if ninet != nil then nil else set lCurrentDl = [url req]::lCurrentDl; if (code == 0) then ( if !voyagerDebugMode then nil else _fooS strcat ">>>>>>> Voyager http data : " data; mutate params <- [_ _ _ (strcat str data)]; 0; ) else if (code == 1) then let if data == nil then str else strcat str data -> str in ( set lCurrentDl = remove_sid_from_list lCurrentDl url; if !voyagerDebugMode then nil else _fooS strcat ">>>>>>> Voyager http result : " str; exec cbfun with [str]; 0; ) else ( set lCurrentDl = remove_sid_from_list lCurrentDl url; exec cberror with [str]; if !voyagerDebugMode then nil else _fooS ">>>>>>>>> VOYAGER http download failed !"; 0; ); ); 0;; fun cbPostIsInternetOk(turl, p, rc) = let p -> [url urlparams cbfun cberror] in if rc == 1 then // ok ( INETGetURLex2 _channel "POST" url "content-type: application/x-www-form-urlencoded" urlparams 0 @cbGetPostUrl [url cbfun cberror ""]; 0; ) else // error ( exec cberror with [""]; 0; ); 0;; fun postUrl(url, urlparams, cbfun, cberror)= _rflINETisConnected sTesturl @cbPostIsInternetOk [url urlparams cbfun cberror]; //INETGetURLex2 _channel "POST" url "content-type: application/x-www-form-urlencoded" urlparams 0 @cbGetPostUrl [url cbfun cberror ""]; 0;; fun cbGetFileDownloadtUrl(req, params, data, code) = let params -> [url destfile file cbfun cberror] in ( let switchstri lCurrentDl url -> ninet in if ninet != nil then nil else set lCurrentDl = [url req]::lCurrentDl; if (code == 0) then ( if !voyagerDebugMode then nil else _fooS strcat ">>>>>>> Voyager http data : " data; _appendpack data file; 0; ) else if (code == 1) then ( set lCurrentDl = remove_sid_from_list lCurrentDl url; if data == nil then nil else _appendpack data file; if !voyagerDebugMode then nil else _fooS strcat ">>>>>>> Voyager http downloaded : " destfile; exec cbfun with [destfile]; 0; ) else ( set lCurrentDl = remove_sid_from_list lCurrentDl url; exec cberror with [destfile]; if !voyagerDebugMode then nil else _fooS ">>>>>>>>> VOYAGER http download failed !"; 0; ); ); 0;; fun cbFileDownloadIsInternetOk(turl, p, rc) = let p -> [url urlparams destfile cbfun cberror] in if rc == 1 then // ok ( _deletepack _checkpack destfile; INETGetURLex2 _channel "POST" url "content-type: application/x-www-form-urlencoded" urlparams 0 @cbGetFileDownloadtUrl [url destfile (_getmodifypack destfile) cbfun cberror]; 0; ) else // error ( exec cberror with [""]; 0; ); 0;; fun fileDownloadUrl(url, urlparams, destfile, cbfun, cberror)= _rflINETisConnected sTesturl @cbFileDownloadIsInternetOk [url urlparams destfile cbfun cberror]; //INETGetURLex2 _channel "POST" url "content-type: application/x-www-form-urlencoded" urlparams 0 @cbGetPostUrl [url cbfun cberror ""]; 0;; fun cbDlIsInternetOk(turl, p, rc) = let p -> [url cbfun cberror] in if rc == 1 then // ok ( INETGetURL _channel url 0 @cbGetPostUrl [url cbfun cberror ""]; 0; ) else // error ( exec cberror with [""]; 0; ); 0;; fun downloadUrl(url, cbfun, cberror)= _rflINETisConnected sTesturl @cbDlIsInternetOk [url cbfun cberror]; //INETGetURL _channel url 0 @cbGetPostUrl [url cbfun cberror ""]; //INETGetURLex2 _channel "GET" url "content-type: application/x-www-form-urlencoded" nil 0 @cbGetPostUrl [url cbfun cberror ""]; 0;; /*----------*/ fun getPathFile (longfile, file)= // lib. Marc Barilley if (longfile==nil) || (strlen longfile)==0 || (nth_char longfile ((strlen longfile)-1)) == '/ then [longfile file] else getPathFile substr longfile 0 (strlen longfile)-1 strcat substr longfile ((strlen longfile)-1) 1 file;; fun brwSearchLastSlash(s)= if s == nil then nil else let strlen s -> n in let n-1 -> i in ( while (i >=0) && ((nth_char s i) != '/) do set i = i-1; i );; fun brwSearchLastpoint(s)= if s == nil then nil else let (strlen s) - 1 -> i in ( while (i >= 0) && ((nth_char s i) != '.) do ( set i = i - 1; ); i );; fun lastpercent(n,i,l)= if i >= strlen n then l else lastpercent n i+1 if (nth_char n i)=='% then i else l;; fun getFatherDirectory(rep)= if rep == nil then nil else ( set rep= substr rep 0 (strlen rep)-1; let brwSearchLastSlash rep -> pos in substr rep 0 pos+1; );; fun getFileWithoutExtension(file)= let brwSearchLastpoint file -> i in substr file 0 i;; fun getExtension(file, ext)= let brwSearchLastpoint file -> i in if !strcmp ext substr file i 10 then 1 else 0;; fun getExtensionFromFile(file)= let brwSearchLastpoint file -> i in substr file i 10;; fun findLastSlash(str)= let 0 -> i in let (strfind "/" str 0) + 1 -> npos in while npos != nil do ( set i = npos; set npos = (strfind "/" str npos) + 1; i );; fun ChgChars(src, dst, c1, c2, n) = if (n == strlen src) then dst else if !strcmp (substr src n 1) c1 then ChgChars src (strcat dst c2) c1 c2 (n + 1) else ChgChars src (strcat dst (substr src n 1)) c1 c2 (n + 1);; fun apply_on_list(l,f,x)= if l==nil then 0 else let l -> [a nxt] in (exec f with [a x]; apply_on_list nxt f x);; /*----------*/ fun removef_from_list(l, f, x)= if l==nil then nil else let l -> [a next] in if exec f with [a x] then next else a::removef_from_list next f x;; /*----------*/ fun listcat (p, q)= if p==nil then q else let p -> [h nxt] in h::listcat nxt q;; /*----------*/ fun posf_in_list (l, f, x)= if l==nil then nil else if exec f with [hd l x] then 0 else 1+posf_in_list tl l f x;;