/* Download Server - DMS - April 2002 - by Bob Le Gob */ /* Rev. 1.1 - February 2003 - by Bob Le Gob */ /******************************************************************************* Variables *******************************************************************************/ var sFilesDef = "";; /* Strbuildt list of files with their sizes */ /******************************************************************************* Functions *******************************************************************************/ /******************************************************************************* RegisterFile() - Registering file and adding it to registered files list l -> [[S r1] r1] : Current list of registered files str -> S : File name p -> I : 0-"reg" , 1-"regF" / Type of file registration <- [[S r1] r1] : Updated list of registered files *******************************************************************************/ fun RegisterFile(l, str, p) = let _getpack _checkpack str -> fileContent in if (p == 0) then let strlen zip fileContent -> zipSize in ( _RSregister this str p fileContent; (str::(itoa zipSize)::nil)::l; ) else let strlen fileContent -> fileSize in ( _RSregister this str p str; (str::(itoa fileSize)::nil)::l; );; /******************************************************************************* RegisterFiles() - Registering files to download src -> [[S r1] r1] : Data from DMI block dst -> [[S r1] r1] : Currently being buildt list of registered files with sizes <- [[S r1] r1] : Buildt list of registered files with sizes *******************************************************************************/ fun RegisterFiles(src, dst) = if (src == nil) then dst else let hd src -> [h t] in if !strcmp h "fd_reg" then ( if ((_checkpack hd t) != nil) then ( set dst = RegisterFile dst hd t 0; 0; ) else ( _adderror strcatn "##Error registering file : "::(hd t)::nil; 0; ); RegisterFiles tl src dst; ) else if !strcmp h "fd_regF" then ( if ((_checkpack hd t) != nil) then ( set dst = RegisterFile dst hd t 1; 0; ) else ( _adderror strcatn "##Error registering file : "::(hd t)::nil; 0; ); RegisterFiles tl src dst; ) else RegisterFiles tl src dst;; /******************************************************************************* Client handling *******************************************************************************/ /******************************************************************************* the client part of the module has been deleted cli -> CLIENT : the client <- I : nothing special (always 0) *******************************************************************************/ fun cbDeleteClient (cli) = _DMSeventTag this CtoU cli "ended" nil nil nil; 0;; /******************************************************************************* destroys a client from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : not used others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbDestroy (from, user, action, param, others, tag) = let UtoC user -> cli in ( _DMSdelClientDMI this cli; _DMSeventTag this user "destroyed" nil nil nil; ); 0;; /******************************************************************************* creates a client from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : parameters of the action others -> [User r1] : not used tag -> Tag : not used p -> S : List of files to download - strbuild format <- I : nothing special *******************************************************************************/ fun cbStart (from, user, action, param, others, tag, p) = if _DMScreateClientDMI this UtoC user p then _DMSeventTag this user "started" nil nil nil else nil; 0;; /******************************************************************************* Module instanciation *******************************************************************************/ /******************************************************************************* Standard IniDMI s -> S : Not used <- I : Not used *******************************************************************************/ fun IniDMI(file)= set sFilesDef = strbuild RegisterFiles strextr _getpack _checkpack file nil; _DMSregister this nil @cbDeleteClient nil; _DMSdefineActions this (["start" (mkfun7 @cbStart sFilesDef)]):: (["destroy" @cbDestroy]):: nil; 0;;