/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : Module.pkg */ /* Version : 19 Mai 2000 */ /* Module struct and basic functions */ /* */ /***************************************************************************************/ /**************************************************************************************** STRUCT ****************************************************************************************/ struct Module = [ MODname : S , /* module name */ MODkey : I , /* key to identify the module during the SCS session */ MODserver : I , /* associated server number */ MODdefinitions : [[S [[S r1] r1]] r1] , /* associated definitions WARNING : for link and zone association there are not in the definitions */ MODposition : [I I] , /* module position in workspace */ MODclass : ModuleClass , /* associated class */ MODlinks : [[Link r1] r1] , /* associated links : grouped by distant module */ MODnode : [Module r1 r1 r1 r1] ] hmkModule /* h prefix means that this constructor is hidden by another which name is in this case: mkModule */ ;; /**************************************************************************************** The key is automatically generated that's why the constructor is replaced by the following function. ****************************************************************************************/ proto SCSDATA_GetCurrentKeyModule = fun [] I;; fun mkModule (params) = let params -> [name server def pos class links] in hmkModule [ name SCSDATA_GetCurrentKeyModule server def pos class links nil] ;; /**************************************************************************************** CONST ****************************************************************************************/ var MOD_BLOCK_DMI = "dmi";; var MOD_BLOCK_LINK = "link";; var MOD_BLOCK_ZONE = "zone";; var MOD_BLOCK_SCS = "scs";; var MOD_BLOCK_DEF = "def";; var MOD_BLOCK_CLIENT = "docclient";; var MOD_BLOCK_SERVER = "docserver";; var MOD_BLOCK_PROPERTIES = "properties";; /* mod block for black box in out rename */ var MOD_BLOCK_REN = "ren";; var MOD_DEF_BB_IN = "in";; var MOD_DEF_BB_OUT = "out";; var MOD_DEF_EVENT_S = "event";; var MOD_DEF_EVENT_C = "eventc";; var MOD_DEF_ACTION_S = "action";; var MOD_DEF_ACTION_C = "actionc";; var MOD_DEF_ZONE = "zone";; var MOD_DEF_ZONE_S = "zone";; var MOD_DEF_DOC = "doc";; var MOD_DEF_ZONE_C = "zoneC";; var MOD_DEF_ZONE_S2 = "zoneS";; var MOD_DEF_BITMAP = "bitmap";; var MOD_DEF_NAME = "name";; var MOD_DEF_POSITION = "position";; var MOD_DEF_CLASS = "class";; var MOD_DEF_ENDDOC = "enddoc";; var MOD_DEF_PORT = "port";; var MOD_DEF_TIMEOUT = "timeout";; var MOD_DEF_DIRECTORY = "directory";; var MOD_DEF_CAPACITY = "capacity";; var MOD_DEF_SATELLITE = "satelite_servers";; var MOD_DEF_VERSION = "version";; var MOD_DEF_DATE = "date";; var MOD_DEF_SCOLFILECONTENT = "scol_file_content";; var MOD_DEF_SATSCOLCONTENT = "satellite_scol_content";; var MOD_DEF_PASSWORD = "password";; var MOD_DEF_SERVER = "server";; var MOD_DEF_CLIENT = "client";; /* For compatibility with upload control center */ var MOD_DEF_SITENAME = "SiteName";; var MOD_DEF_AUTHORNAME = "AuthorName";; var MOD_DEF_AUTHOREMAIL = "AuthorEmail";; var MOD_DEF_SITEDESC = "SiteDescription";; var MOD_DEF_LANG = "Lang";; var MOD_DEF_SCREENSHOT = "ModelScreenshot";; var NOT_START_MODULE_NAME = "."::nil;; /**************************************************************************************** Interface function prototypes ****************************************************************************************/ proto MODULE_Load = fun [Site Module S I [[S [[S r1] r1]] r1] [I I] ModuleClass] Module;; proto MODULE_SetName = fun [Site Module S I] I;; proto MODULE_SetServer = fun [Module I] I;; proto MODULE_GetFather = fun [Site Module] Module;; proto MODULE_GetChildren = fun [Site Module] [Module r1];; proto MODULE_GetBrothers = fun [Site Module] [Module r1];; proto MODULE_GetZonesCS = fun [Module I] [S r1];; /**************************************************************************************** Get the module key ****************************************************************************************/ fun MODULE_GetKey (module) = module.MODkey;; /**************************************************************************************** Get a module in a module list according to its key. nil is returned if not find . ****************************************************************************************/ fun MODULE_GetByKey (modlist, key) = let modlist -> [first next] in if first==nil then nil else if (MODULE_GetKey first)==key then first else MODULE_GetByKey next key;; /**************************************************************************************** COMPARISON AND CHECK FUNCTION ****************************************************************************************/ fun MODULE_CompareName (module, name) = ! strcmpi module.MODname name ;; fun MODULE_CompareStrByName (module1, module2) = strcmpi module1.MODname module2.MODname ;; /**************************************************************************************** Check for a name's validity Return value: 1 (success) or 0 (failure) ****************************************************************************************/ /* MAT ICI CURRENT */ fun MODULE_CheckNameValidity (name, logIfError) = /* MAT ICI crade */ if name == nil || !strcmp name "" then { if logIfError then ERRORS_AddError 0 11 strcatn (_locSCS "errorlabel-11" nil)::": "::name::nil else nil; logScsError "MODULE_CheckNameValidity" nil "Name is nil or empty" 0 } else let substr name 0 1 -> debut in if str_and_list_cmpi debut NOT_START_MODULE_NAME then { ERRORS_AddError 0 11 strcatn (_locSCS "errorlabel-11" nil)::": "::name::nil; logScsError "MODULE_CheckNameValidity" "name:"::name::nil "Invalid first character for module name" 0 } else 1 ;; /**************************************************************************************** Check for a name's unicity in a module list other than module Return value: 1 (success) or 0 (failure) ****************************************************************************************/ fun MODULE_CheckNameUnicity (moduleList, name, otherModule) = if moduleList == nil then 1 else let moduleList -> [module nextModule] in if !(strcmpi module.MODname name) then if (module == otherModule) then 1 else 0 else (MODULE_CheckNameUnicity nextModule name otherModule) ;; /**************************************************************************************** Check for a server number's validity Return value: 1 (success) or 0 (failure) ****************************************************************************************/ fun MODULE_CheckNumServer (serverNum) = serverNum >= 0 ;; /**************************************************************************************** create root module ****************************************************************************************/ proto SCSDATA_GetBlackBoxClass = fun [] ModuleClass;; fun MODULE_CreateRoot () = let SCSDATA_GetBlackBoxClass -> class in mkModule [ nil 0 nil nil class nil ] ;; fun MODULE_IsBlackBox (module)= (! strcmpi module.MODclass.MODCname BLACKBOX_NAME) ;; /**************************************************************************************** return the path name of module1 for a link from module2 to module1 ****************************************************************************************/ fun MODULE_GetPathName (site, module1, module2) = if (MODULE_GetFather site module1) == module2 then strcat "." (module1.MODname) else if is_in_list MODULE_GetChildren site module1 module2 then ".." else (module1.MODname) ;; /**************************************************************************************** links a module to its node ****************************************************************************************/ fun MODULE_MkNode( module )= set module.MODnode = TREE_MkNode module ;; fun MODULE_GetNode( module )= module.MODnode ;; fun MODULE_Print (module) = strcatn "["::module.MODname::"] ("::module.MODclass.MODCname::")"::nil ;; fun MODULE_PrintList (moduleList) = if moduleList == nil then nil else (MODULE_Print hd moduleList)::(MODULE_PrintList tl moduleList) ;;