/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : SiteParse.pkg */ /* Version : 08 Aout 2000 */ /* Site data parsing functions */ /* */ /***************************************************************************************/ proto MODULE_LoadLink = fun [Site Module S Module S S S] Link;; /*************************************************************************************** LOAD ***************************************************************************************/ /*************************************************************************************** Return a module class Return value: ModuleClass (success) or nil (failure) NOTE: a nil filename means the module is a black box ***************************************************************************************/ proto SCSDATA_SearchClassByFileName = fun [S] ModuleClass;; fun SITE_GetClass (filename) = if filename == nil then SCSDATA_GetBlackBoxClass else SCSDATA_SearchClassByFileName filename ;; /*************************************************************************************** Parse the module subtree Return value: [Module r1 r1 r1 r1] (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseSubModule (site, node, listDef, Channel) = if listDef == nil then 1 else let listDef -> [def next] in ( SITE_ParseModule site node def Channel; SITE_ParseSubModule site node next Channel ) ;; /*************************************************************************************** Parse the module tree Return value: [Module r1 r1 r1 r1] (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseModule (site, node, def, Channel) = if def == nil then nil else let SITE_GetClass getInfo (_DEFgetDef def MOD_BLOCK_DMI) MOD_DEF_CLASS -> class in if class == nil then ( ERRORS_AddError 1 34 strcatn (_locSCS "errorlabel-34" nil)::": "::def.nameDEF::nil; nil ) else let (getInfos (_DEFgetDef def MOD_BLOCK_SCS) MOD_DEF_POSITION) -> [x [y _]] in let MODULE_Load site (TREE_Val node) def.nameDEF def.srvDEF def.listDEF [(atoi x) (atoi y)] class -> module in if module == nil then nil else let MODULE_MkNode module -> moduleNode in ( SITE_ParseSubModule site moduleNode def.subDEF Channel; TREE_AddNodeToChildTail node moduleNode; moduleNode ) ;; /*************************************************************************************** Parse the module tree root Return value: [Module r1 r1 r1 r1] (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseModuleRoot (site, def, Channel) = if def == nil then nil else let SITE_GetClass (getInfo (_DEFgetDef def MOD_BLOCK_DMI) MOD_DEF_CLASS) -> class in let (getInfos (_DEFgetDef def MOD_BLOCK_SCS) MOD_DEF_POSITION) -> [x [y _]] in let MODULE_Load site nil (getInfo (_DEFgetDef def MOD_BLOCK_DEF) MOD_DEF_NAME) MASTERNUMBER def.listDEF [(atoi x) (atoi y)] class -> moduleRoot in let MODULE_MkNode moduleRoot -> moduleRootNode in ( /* add black box default dmi values */ MODULE_AddDefLineList moduleRoot MOD_BLOCK_DMI ROOT_DMI; SITE_ParseSubModule site moduleRootNode def.subDEF Channel; moduleRootNode ) ;; /*************************************************************************************** Parse a module subtree's links Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun SITE_ParseSubLink (site, listModule) = if listModule == nil then 1 else let listModule -> [module nextModule] in ( SITE_ParseLink site module (MODULE_GetDefBlock module MOD_BLOCK_LINK); SITE_ParseSubLink site nextModule ) ;; /*************************************************************************************** Parse a module's links Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun SITE_ParseLink (site, moduleSrc, listLink) = if listLink == nil then SITE_ParseSubLink site (MODULE_GetChildren site moduleSrc) else let listLink -> [[event [nameDest [action [parameter [ignored [condition _]]]]]] nextLink] in let [(Tunder parameter) (Tunder condition)] -> [parameter condition] in ( if !strcmp nameDest ".." then /* destination module is the father */ MODULE_LoadLink site moduleSrc event (MODULE_GetFather site moduleSrc) action parameter condition else if !strcmp (substr nameDest 0 1) "." then /* destination module is a child */ let SITE_GetModuleByName site (MODULE_GetChildren site moduleSrc) (substr nameDest 1 ((strlen nameDest) - 1)) -> moduleDest in MODULE_LoadLink site moduleSrc event moduleDest action parameter condition else /* destination module is a brother */ let SITE_GetModuleByName site (MODULE_GetBrothers site moduleSrc) nameDest -> moduleDest in MODULE_LoadLink site moduleSrc event moduleDest action parameter condition ; SITE_ParseLink site moduleSrc nextLink ) ;; /*************************************************************************************** Parse a module subtree's zone associations Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun SITE_ParseSubAssociation (site, listModule) = if listModule == nil then 1 else let listModule -> [module nextModule] in ( SITE_ParseAssociation site module (MODULE_GetDefBlock module MOD_BLOCK_ZONE); SITE_ParseSubAssociation site nextModule ) ;; /*************************************************************************************** Parse a module's zone associations Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun SITE_ParseAssociation (site, moduleSrc, listAsso) = if listAsso == nil then SITE_ParseSubAssociation site (MODULE_GetChildren site moduleSrc) else let listAsso -> [[type [name [zoneDestName _]]] nextAsso] in ( let SITE_GetZoneByCompleteName (if !strcmpi type MOD_DEF_ZONE_S2 then site.SITEserverZonesTreeRoot else site.SITEclientZonesTreeRoot) splitString zoneDestName "." -> zoneDest in if zoneDest == nil then /* ERROR NOT SENT TO END-USER */ logScsError "SITE_ParseAssociation" nil "zone not found for zone association" nil else ASSO_RealAddAssociation site zoneDest moduleSrc name; SITE_ParseAssociation site moduleSrc nextAsso ) ;; /*************************************************************************************** Parse old format zone tree ***************************************************************************************/ fun SITE_ParseZone (defLines, site, fatherZone) = if defLines == nil then nil else let hd hd defLines -> typeZone in if !strcmpi typeZone MOD_DEF_ENDDOC then tl defLines else let tl hd defLines -> [name suite] in if !strcmpi typeZone MOD_DEF_DOC then let ZONE_Add site fatherZone ZONE_POPUP -> newZone in ( set newZone.ZONEname = name; ZONE_ParseDOC newZone suite; let SITE_ParseZone tl defLines site newZone -> suiteDefLines in SITE_ParseZone suiteDefLines site fatherZone ) else if !strcmpi typeZone MOD_DEF_ZONE then let ZONE_Add site fatherZone ZONE_ZONE -> newZone in ( set newZone.ZONEname = name; ZONE_ParseZONE newZone suite; SITE_ParseZone tl defLines site fatherZone ) else /* ERROR NOT SENT TO END-USER */ logScsError "SITE_ParseZone" "line :"::typeZone::nil "invalid zone type in definition line" nil ;; /*************************************************************************************** Parse zone tree root Return value: [Zone r1 r1 r1 r1] (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseZoneRoot (site, defLines, sideFlag) = if defLines == nil then /* ERROR NOT SENT TO END-USER */ logScsError "SITE_ParseZoneRoot" nil "no definition data found" nil else if ZONE_VerifyRootData hd defLines sideFlag then let ZONE_CreateRoot sideFlag -> zoneRoot in let TREE_MkNode zoneRoot -> zoneRootNode in ( if sideFlag == SCS_CLIENT then set site.SITEclientZonesTreeRoot = zoneRootNode else set site.SITEserverZonesTreeRoot = zoneRootNode; ZONE_ParseDOC zoneRoot (tl tl hd defLines); SITE_ParseZone tl defLines site zoneRoot; zoneRootNode ) else /* ERROR NOT SENT TO END-USER */ logScsError "SITE_ParseZoneRoot" "line :"::(linebuild hd defLines)::nil "invalid root zone definition line" nil ;; /*************************************************************************************** SAVE ***************************************************************************************/ fun SITE_GetZoneDef (zoneTree) = if zoneTree == nil then nil else let TREE_Val zoneTree -> zone in ( listcat ((if ZONE_IsDoc zone then MOD_DEF_DOC else MOD_DEF_ZONE):: (ZONE_GetDataDef zone)):: (SITE_GetZoneDef TREE_FirstChild zoneTree) ( let SITE_GetZoneDef TREE_NextBrother zoneTree -> brotherDat in (if ZONE_IsDoc zone then (MOD_DEF_ENDDOC::nil)::brotherDat else brotherDat) ) ) ;; /*************************************************************************************** Parse a module's sub definitions Return value: DEF (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseModuleSubDef (site, moduleList) = if moduleList == nil then nil else let moduleList -> [module nextModule] in (SITE_ParseModuleDef site module):: (SITE_ParseModuleSubDef site nextModule) ;; /*************************************************************************************** Parse a module's definitions Return value: DEF (success) or nil (failure) ***************************************************************************************/ fun SITE_ParseModuleDef (site, module) = if module == nil then nil else ( MODULE_UpdateDefinition site module; if MODULE_IsBlackBox module then MODULE_SetDefLine module MOD_BLOCK_DMI MOD_DEF_CLASS nil else nil; mkDEF [ module.MODname module.MODserver module.MODdefinitions SITE_ParseModuleSubDef site (MODULE_GetChildren site module) ] ) ;; fun SITE_ParseProperties (deflines) = if deflines == nil then nil else let deflines -> [cur next] in [(hd cur) (hd tl cur)]::(SITE_ParseProperties next) ;; fun SITE_ParseServers (serversList) = if serversList == nil then nil else let serversList -> [num [ip [port next]]] in [num ip port]::(SITE_ParseServers next) ;; /**************************************************************************************** parse site main options definitions ****************************************************************************************/ fun SITE_ParseOptions (site, deflines) = if deflines == nil then /* ERROR NOT SENT TO END-USER */ logScsError "SITE_ParseSiteOptions" nil "no definition data found" nil else ( /* JOOL ICI - manque des tests sur la présence ou non des paramètres */ set site.SITEoptions.SITEname = getInfo deflines MOD_DEF_NAME; set site.SITEoptions.SITEpassword = getInfo deflines MOD_DEF_PASSWORD; set site.SITEoptions.SITEdirectory = getInfo deflines MOD_DEF_DIRECTORY; set site.SITEoptions.SITEportNumber = atoi getInfo deflines MOD_DEF_PORT; set site.SITEoptions.SITEtimeout = atoi getInfo deflines MOD_DEF_TIMEOUT; set site.SITEoptions.SITEloadCapacity = atoi getInfo deflines MOD_DEF_CAPACITY ; let atoi getInfo deflines MOD_DEF_VERSION -> value in set site.SITEoptions.SITEversion = if value == nil then 0 else value; set site.SITEoptions.SITEdate = getInfo deflines MOD_DEF_DATE ; set site.SITEservers = SITE_ParseServers (getInfos deflines MOD_DEF_SATELLITE); set site.SITEoptions.SITEscolFileContent = (getInfo deflines MOD_DEF_SCOLFILECONTENT); set site.SITEoptions.SITEsatelliteScolFileContent = (getInfo deflines MOD_DEF_SATSCOLCONTENT); let getInfo deflines MOD_DEF_AUTHORNAME -> value in set site.SITEoptions.SITEauthorName = (if value == nil then PARAMS_GetS SCSparameters "SITE_DEFAULT_AUTHORNAME" else value) ; let getInfo deflines MOD_DEF_AUTHOREMAIL -> value in set site.SITEoptions.SITEauthorEmail = (if value == nil then PARAMS_GetS SCSparameters "SITE_DEFAULT_AUTHOREMAIL" else value) ; let getInfo deflines MOD_DEF_SITEDESC -> value in set site.SITEoptions.SITEdescription = (if value == nil then PARAMS_GetS SCSparameters "SITE_DEFAULT_SITEDESC" else value) ; let getInfo deflines MOD_DEF_LANG -> value in set site.SITEoptions.SITElang = (if value == nil then PARAMS_GetS SCSparameters "SITE_DEFAULT_SITELANG" else value) ; let getInfo deflines MOD_DEF_SCREENSHOT -> value in set site.SITEoptions.SITEscreenshotName = (if value == nil then PARAMS_GetS SCSparameters "SITE_DEFAULT_SCREENSHOTFILENAME" else value) ; ) ;; /**************************************************************************************** return site main options definitions ****************************************************************************************/ fun SITE_GetOptionnalOptionsDef (site) = if site.SITEoptions.SITEdirectory == nil then if site.SITEoptions.SITEloadCapacity == nil then nil else (MOD_DEF_CAPACITY::(itoa site.SITEoptions.SITEloadCapacity)::nil)::nil else if site.SITEoptions.SITEloadCapacity == nil then (MOD_DEF_DIRECTORY::(site.SITEoptions.SITEdirectory)::nil)::nil else (MOD_DEF_DIRECTORY::(site.SITEoptions.SITEdirectory)::nil)::(MOD_DEF_CAPACITY::(itoa site.SITEoptions.SITEloadCapacity)::nil)::nil ;; fun SITE_GetSatellitesDef (servers) = if servers == nil then nil else let hd servers -> [num ip port] in num::ip::port::(SITE_GetSatellitesDef tl servers) ;; fun SITE_GetOptionsDef (site) = listcat (MOD_DEF_NAME::(site.SITEoptions.SITEname)::nil):: (MOD_DEF_PASSWORD::(site.SITEoptions.SITEpassword)::nil):: (MOD_DEF_VERSION::(itoa site.SITEoptions.SITEversion)::nil):: (MOD_DEF_DATE::(site.SITEoptions.SITEdate)::nil):: (MOD_DEF_PORT::(itoa site.SITEoptions.SITEportNumber)::nil):: (MOD_DEF_TIMEOUT::(itoa site.SITEoptions.SITEtimeout)::nil):: (MOD_DEF_SITENAME::(site.SITEoptions.SITEname)::nil):: (MOD_DEF_AUTHORNAME::(site.SITEoptions.SITEauthorName)::nil):: (MOD_DEF_AUTHOREMAIL::(site.SITEoptions.SITEauthorEmail)::nil):: (MOD_DEF_SITEDESC::(site.SITEoptions.SITEdescription)::nil):: (MOD_DEF_LANG::(site.SITEoptions.SITElang)::nil):: (MOD_DEF_SCREENSHOT::(site.SITEoptions.SITEscreenshotName)::nil):: (MOD_DEF_SATELLITE::(SITE_GetSatellitesDef site.SITEservers)):: (MOD_DEF_SCOLFILECONTENT::(site.SITEoptions.SITEscolFileContent)::nil):: (MOD_DEF_SATSCOLCONTENT::(site.SITEoptions.SITEsatelliteScolFileContent)::nil):: nil SITE_GetOptionnalOptionsDef site ;; fun SITE_GetPropertiesDef (proplist) = if proplist == nil then nil else let proplist -> [cur next] in let cur -> [key val] in (key::val::nil)::SITE_GetPropertiesDef next ;; proto SITE_ForceAllServerNumber = fun [DEF I] I;; fun SITE_ForceAllServerNumber (def, value) = if def == nil then nil else ( set def.srvDEF = value; apply_on_list def.subDEF @SITE_ForceAllServerNumber value; 0 ) ;; fun SITE_CompareSatelliteServer (elt, param) = let elt -> [id _] in !strcmpi id MOD_DEF_SATELLITE ;; fun SITE_ClearSatelliteServerRec (deflist) = if deflist == nil then nil else let deflist -> [cur next] in let cur -> [idBlock list] in if !strcmpi idBlock MOD_BLOCK_DEF then [idBlock (removef_from_list list @SITE_CompareSatelliteServer nil)]::next else cur::(SITE_ClearSatelliteServerRec next) ;; fun SITE_ClearSatelliteServer (def) = set def.listDEF = SITE_ClearSatelliteServerRec def.listDEF ;;