/* Count Server - DMS - March 98 - by Sylvain HUET */ defcom Cstart=start S;; defcom Csend=send S;; defcom Ctoday=today S;; typeof text=ObjText;; typeof file=S;; struct Tmp= [month:S,day:S,hour:I, dayhits:tab I,totalhits:I]mkTmp;; typeof tmp=Tmp;; fun conc(p,q)= if p==nil then q else (hd p)::conc (tl p) q;; fun getTime()= let hd strextr ctime time -> l in [nth_list l 1 strcat nth_list l 2 nth_list l 0 atoi substr nth_list l 3 0 2];; fun iniTmp()= let getTime->[m d h] in mkTmp[m d h mktab 24 0 0];; fun getTab(t,i,j)= if i>=j then nil else (itoa t.i)::getTab t i+1 j;; fun TmpToA(t)= strbuild (conc t.month::t.day::nil conc getTab t.dayhits 0 24 (itoa t.totalhits)::nil)::nil;; fun sublist(l,n)= if n then (atoi hd l)::sublist tl l n-1 else nil;; fun AToTmp(ll,t)= let hd ll->l in (set t.month=nth_list l 0; set t.day=nth_list l 1; set t.dayhits=listtotab sublist endlist l 2 24; set t.totalhits=atoi nth_list l 26);; fun storeMonth(t)= _appendpack TmpToA t _getmodifypack strcatn file::"."::t.month::".log"::nil;; fun updateTmp()= _SETtext text strcatn (_loc this "CNT_HITS" nil)::" : "::(itoa tmp.totalhits)::nil; _storepack TmpToA tmp file;; fun _clockE(a,b)= let getTime->[m d h] in if tmp.hour==h && (!strcmp tmp.month m) && (!strcmp tmp.day d) then nil else (set tmp.hour=h; if (!strcmp tmp.month m) && (!strcmp tmp.day d) then nil else (storeMonth tmp; set tmp=mkTmp[m d h mktab 24 0 tmp.totalhits]); updateTmp);; fun hit(cli)= set tmp.dayhits.(tmp.hour)=1+tmp.dayhits.(tmp.hour); set tmp.totalhits=1+tmp.totalhits; updateTmp; 0;; fun activate(from,cli,action,param,rep)= _clockE nil nil; if !strcmp action "hit" then hit cli else if !strcmp action "show" then _DMScreateClientDMI this cli nil else if !strcmp action "hide" then _DMSdelClientDMI this cli else nil;; fun startStat()= set tmp=iniTmp; let strextr _getpack _checkpack file->l in if (sizelist hd l)!=27 then nil else AToTmp l tmp; _rfltimer _starttimer _channel 60000 @_clockE 0; _clockE nil nil; updateTmp; 0;; fun _resizeI(x,s)= let x->[win x y w h] in _SIZEtext text w h x y; 0;; fun IniDMI(param)= _DMSregisterDMI this @activate nil nil nil; let strextr _getpack _checkpack param ->l in (set file=getInfo l "file"); let _DMSgetZone this "Count" nil @_resizeI nil ->[win x y w h] in if win==nil then nil else set text=_CRtext _channel win x y w h ET_DOWN+ET_AHSCROLL ""; startStat;; fun __getmonth(m)= let strcatn file::"."::m::".log"::nil -> f in (_DMSsend this DMSsender Cstart [f]; let _getpack _checkpack f -> s in if s==nil then nil else let strlen s -> sz in let 0->i in while i