home *** CD-ROM | disk | FTP | other *** search
- /****************************/
- /* Interactive area manager */
- /*****************************************/
- /* $VER: LocalAreaFix.ems 1.0 (29.07.93) */
- /*****************************************/
-
- options results
- signal on error
- signal on syntax
-
- if ~show( 'l', "rexxsupport.library" ) then
- do
- if ~addlib( "rexxsupport.library", 0, -30, 0 ) then
- do
- say "Could not open rexxsupport.library"
- exit 10
- end
- end
-
- if ~show( 'l', "ems_rexx.library" ) then
- do
- if ~addlib( "ems_rexx.library", 0, -30, 0 ) then
- do
- say "Could not open ems_rexx.library"
- exit 10
- end
- end
-
-
- /****************************/
- /* Initialize some stuff... */
- /****************************/
- cmds.1 = 'Edit Links (using Node)'
- cmds.2 = 'Edit Links (using Area)'
- cmds.3 = 'Edit Groups (using a Node)'
- cmds.4 = 'Edit Groups (using an Area)'
- cmds.5 = 'Rescan'
- cmds.6 = 'Delete Backup Config'
- cmds.7 = 'Restore Backup Config'
- cmds.0 = 7
-
- cfg_names.1 = 'AKAs' ; cfg_int.1 = 'cfg_aka_ems'
- cfg_names.2 = 'Archivers' ; cfg_int.2 = 'cfg_archiver_ems'
- cfg_names.3 = 'Areas' ; cfg_int.3 = 'cfg_area_ems'
- cfg_names.4 = 'Domains' ; cfg_int.4 = 'cfg_domain_ems'
- cfg_names.5 = 'Externals' ; cfg_int.5 = 'cfg_external_ems'
- cfg_names.6 = 'Links' ; cfg_int.6 = 'cfg_link_ems'
- cfg_names.7 = 'Nodes' ; cfg_int.7 = 'cfg_node_ems'
- cfg_names.8 = 'Routing' ; cfg_int.8 = 'cfg_routing_ems'
- cfg_names.9 = 'Switches' ; cfg_int.9 = 'cfg_switch_ems'
- cfg_names.10 = 'Userlist' ; cfg_int.10 = 'cfg_userlist_ems'
- cfg_names.11 = 'Variables' ; cfg_int.11 = 'cfg_variable_ems'
- cfg_names.0 = 11
-
-
- call EMS_Nodes( 'nodes' )
- call EMS_Areas( 'areas', 'SORT' )
-
-
- do forever
-
- sel = -1
- res = EMS_Do_Choice_Single( 'Choose Section', 'cmds', 'sel' )
-
- if res ~= 'OK' then leave
-
- select
- when sel = 1 then call Cmd_Edit_Links_Node()
- when sel = 2 then call Cmd_Edit_Links_Area()
- when sel = 3 then call Cmd_Edit_Groups_Node()
- when sel = 4 then call Cmd_Edit_Groups_Area()
- when sel = 5 then call Cmd_Rescan()
- when sel = 6 then call Cmd_Delete_Backup_Config()
- when sel = 7 then call Cmd_Restore_Backup_Config()
- otherwise nop
- end
-
- end
-
- QuitScript:
-
- call EMS_Cfg_Write( 'cfg_area_ems' )
- call EMS_Cfg_Write( 'cfg_link_ems' )
- call EMS_Cfg_Write( 'cfg_node_ems' )
-
- call EMS_FreeScriptData()
- return 0
-
-
- error:
- syntax:
-
- error_text = EMS_LastError()
-
- if error_text = '' then error_text = rc ErrorText( rc )
-
- say '| ***BREAK: error at' sigl error_text
-
- call EMS_Cfg_Write( 'cfg_area_ems' )
- call EMS_Cfg_Write( 'cfg_link_ems' )
- call EMS_Cfg_Write( 'cfg_node_ems' )
-
- call EMS_FreeScriptData()
- exit rc
-
-
-
- Cmd_Edit_Links_Node: procedure EXPOSE areas. nodes.
-
- node = Choose_Node(); if node = '' then return 0
-
- usegroups = Ask_UseGroups()
-
-
- call EMS_Areafix_Node_Links_Get( node, 'actives', 'passives' )
-
- work_areas.0 = 0
- work_status.0 = 0
-
- do i=1 to areas.0
-
- do_add = 0
-
- if EMS_Search_In_Stem( 'actives', areas.i ) ~= 0 then
- do
- status = 'TRUE'
- do_add = 1
- end
- else
- do
- status = 'FALSE'
- end
-
- if usegroups = 0 | EMS_Areafix_Node_MatchGroup( node, areas.i ) = 'TRUE' then do_add = 1
-
- if do_add then
- do
- call EMS_Add_To_Stem( 'work_areas' , areas.i )
- call EMS_Add_To_Stem( 'work_status', status )
- end
-
- end
-
- res = EMS_Do_Choice_Multi( 'Change Linked Areas For Node' node, 'work_areas', 'work_status' )
-
- if res ~= 'OK' then return 0
-
- actives.0 = 0
-
- do i=1 to work_areas.0
-
- if upper( EMS_Area_Type( areas.i ) ) = 'MAIL' then iterate
-
- if work_status.i = 'TRUE' then call EMS_Add_To_Stem( 'actives', work_areas.i, 'UNIQUE' )
-
- end
-
- call EMS_Areafix_Node_Links_Set( node, 'actives', 'passives' )
-
- return 0
-
-
-
- Cmd_Edit_Links_Area: procedure EXPOSE areas. nodes.
-
- area = Choose_Area(); if area = '' then return 0
-
- usegroups = Ask_UseGroups()
-
-
- call EMS_Areafix_Area_Links_Get( area, 'actives', 'passives' )
-
- work_nodes.0 = 0
- work_status.0 = 0
-
- do i=1 to nodes.0
-
- do_add = 0
-
- if EMS_Search_In_Stem( 'actives', nodes.i ) ~= 0 then
- do
- status = 'TRUE'
- do_add = 1
- end
- else
- do
- status = 'FALSE'
- end
-
- if usegroups = 0 | EMS_Areafix_Node_MatchGroup( nodes.i, area ) = 'TRUE' then do_add = 1
-
- if do_add then
- do
- call EMS_Add_To_Stem( 'work_nodes' , nodes.i )
- call EMS_Add_To_Stem( 'work_status', status )
- end
-
- end
-
- res = EMS_Do_Choice_Multi( 'Change Linked Nodes For Area' area, 'work_nodes', 'work_status' )
-
- if res ~= 'OK' then return 0
-
- actives.0 = 0
-
- do i=1 to work_nodes.0
-
- if work_status.i = 'TRUE' then call EMS_Add_To_Stem( 'actives', work_nodes.i, 'UNIQUE' )
-
- end
-
- call EMS_Areafix_Area_Links_Set( area, 'actives', 'passives' )
-
- return 0
-
-
-
- Cmd_Edit_Groups_Node: procedure EXPOSE areas. nodes.
-
- node = Choose_Node(); if node = '' then return 0
-
- groups.0 = 0
-
- do i=1 to areas.0
-
- name = EMS_Area_Group_Name( areas.i ); if name = '' then iterate
- level = EMS_Area_Group_Level( areas.i )
-
- call EMS_Add_To_Stem( 'groups', Group_Hash( name , level ), 'UNIQUE' )
-
- end
-
- call EMS_Node_Groups_Get( node, 'node_groups' )
-
- /*
- ** node_groups.x.0 = Name
- ** node_groups.x.1 = Level
- ** node_groups.x.2 = Flags
- */
- do i=1 to node_groups.0
-
- if node_groups.i.0 = '' then iterate
-
- call EMS_Add_To_Stem( 'groups', Group_Hash( node_groups.i.0, node_groups.i.1 ), 'UNIQUE' )
-
- end
-
-
- call EMS_Sort_Stem( 'groups' )
-
- status.0 = 0
-
- do i=1 to groups.0
-
- status.i = 'FALSE'
-
- end
-
-
- do i=1 to node_groups.0
-
- name = Group_Hash( node_groups.i.0, node_groups.i.1 )
- num = 0
-
- do forever
-
- num = EMS_Search_In_Stem( 'groups', name, num ); if num = 0 then leave
-
- status.num = 'TRUE'
-
- end
-
- end
-
-
- work_names.0 = groups.0
- do i=1 to groups.0
-
- parse var groups.i name '/' num
-
- num = Extract_Num( num )
-
- work_names.i = name
- work_nums.i = num
- work_flags.i = ''
-
- end
-
- do i=1 to node_groups.0
-
- num = 0
-
- do forever
-
- num = EMS_Search_In_Stem( 'work_names', node_groups.i.0, num ); if num = 0 then leave
-
- if work_nums.num = node_groups.i.1 then work_flags.num = node_groups.i.2
-
- end
-
- end
-
-
- call EMS_Calc_Stem_Width( 'work_names', 'ADAPT' )
-
- do i=1 to work_names.0
-
- groups.i = work_names.i ' ' work_nums.i
-
- end
-
- res = EMS_Do_Choice_Multi( 'Change Groups For Node' node, 'groups', 'status' )
-
- if res ~= 'OK' then return 0
-
- node_groups.0 = 0
-
- do i=1 to work_names.0
-
- if status.i = 'FALSE' then iterate
-
- j = node_groups.0 + 1
- node_groups.0 = j
- node_groups.j.0 = work_names.i
- node_groups.j.1 = work_nums.i
- node_groups.j.2 = work_flags.i
-
- end
-
- call EMS_Node_Groups_Set( node, 'node_groups' )
-
- return 0
-
-
-
- Cmd_Edit_Groups_Area: procedure EXPOSE areas. nodes.
-
- area = Choose_Area(); if area = '' then return 0
-
- name = EMS_Area_Group_Name( area )
- level = EMS_Area_Group_Level( area )
-
- res = EMS_String_Select( 'Insert New Group Name For' area, 'name' ); if res ~= 'OK' then return 0
- res = EMS_String_Select( 'Insert New Group Level For' area, 'level' ); if res ~= 'OK' then return 0
-
- call EMS_Area_Group_Name( area, name )
- call EMS_Area_Group_Level( area, level )
-
- return 0
-
-
-
- Cmd_Rescan: procedure EXPOSE areas. nodes.
-
- area = Choose_Area(); if area = '' then return 0
-
- call EMS_Areafix_Area_Links_Get( area, 'actives' )
-
- if EMS_Do_Request( 'Rescan All?', 'Yes|No' ) = 'Yes' then mode = 'FORCE'
- else mode = ''
-
- res = EMS_Do_Request( 'How Should I Rescan it?', 'To All|Only A Node' )
-
- if res = 'To All' then
- do
-
- do i=1 to actives.0
-
- call EMS_Tosser_Rescan( area, actives.i, mode )
-
- end
-
- end
- else
- do
-
- sel = -1
- res = EMS_Do_Choice_Single( 'Pick up a node', 'actives', 'sel' )
-
- if res ~= 'OK' then return 0
-
- call EMS_Tosser_Rescan( area, actives.sel, mode )
-
- end
-
- return 0
-
-
-
- Cmd_Delete_Backup_Config: procedure EXPOSE cfg_names.
-
- /* Save Current Directory */
- saved_CD = PRAGMA( 'D' )
-
- call PRAGMA( 'D', 'EMS:Config' )
-
- files = showdir( '', 'F' )
-
- do i=1 to cfg_names.0
-
- call Build_Cfg_List( cfg_names.i, files )
-
- if glob_stem.0 = 0 then iterate
-
- status.0 = glob_stem.0
- do j=1 to glob_stem.0
-
- status.j = 'TRUE'
-
- end
-
- res = EMS_Do_Choice_Multi( 'Config "' || cfg_names.i || '"', 'glob_stem', 'status' )
-
- if res = 'OK' then
- do
-
- do j=1 to glob_stem.0
-
- if status.j = 'TRUE' then call Delete( glob_stem.j )
-
- end
-
- end
-
- end
-
- /* Restore Current Directory */
- call PRAGMA( 'D', saved_CD );
-
- return 0
-
-
-
- Cmd_Restore_Backup_Config: procedure EXPOSE cfg_names. cfg_int. areas. nodes.
-
- sel = -1
- res = EMS_Do_Choice_Single( 'Choose Config To Restore', 'cfg_names', 'sel' )
-
- if res ~= 'OK' then return 0
-
- /* Save Current Directory */
- saved_CD = PRAGMA( 'D' )
-
- call PRAGMA( 'D', 'EMS:Config' )
-
- files = showdir( '', 'F' )
-
- call Build_Cfg_List( cfg_names.sel, files )
-
- if glob_stem.0 = 0 then
- do
-
- call EMS_Do_Request( 'Nothing to restore', 'Ok' )
-
- end
- else
- do
-
- num = -1
- res = EMS_Do_Choice_Single( 'Pick Up The Config To Restore', 'glob_stem', 'num' )
-
- if res = 'OK' then
- do
-
- max = 0
-
- do i=1 to glob_stem.0
-
- parse var glob_stem.i pre '.' pos
-
- if max < pos then max = pos
-
- end
-
- max = max + 1
-
- call Rename( cfg_names.sel, cfg_names.sel || '.' || max )
- call Rename( glob_stem.num, cfg_names.sel )
-
- call EMS_Cfg_Read( cfg_int.sel )
-
- if cfg_stem.sel = 'Nodes' then call EMS_Nodes( 'nodes' )
- if cfg_stem.sel = 'Areas' then call EMS_Areas( 'areas', 'SORT' )
-
- end
-
- end
-
-
-
- files = showdir( '', 'F' )
-
- call Build_Cfg_List( cfg_names.sel, files )
-
- if glob_stem.0 ~= 0 then
- do
-
- do i=1 to glob_stem.0
-
- if glob_stem.i ~= cfg_names.sel || '.' || i then leave
-
- end
-
- if i <= glob_stem.0 then
- do
-
- res = EMS_Do_Request( 'Backup Files Not In Order' || 'A'X || ' Should I Renum Them? ', 'YES|NO' )
-
- if res = 'YES' then
- do
-
- do i=1 to glob_stem.0
-
- if glob_stem.i = cfg_names.sel || '.' || i then iterate
-
- call Rename( glob_stem.i, cfg_names.sel || '.' || i )
-
- end
-
- end
-
- end
-
- end
-
-
-
- /* Restore Current Directory */
- call PRAGMA( 'D', saved_CD );
-
- return 0
-
-
-
- Build_Cfg_List: procedure EXPOSE glob_stem.
-
- parse arg cfg_name, files
-
- glob_stem.0 = 0
-
- do while length( files ) ~= 0
-
- parse var files name files
-
- parse var name pre '.' num
-
- if pre ~= cfg_name then iterate
- if datatype( num, 'N' ) ~= 1 then iterate
-
- call EMS_Add_To_Stem( 'glob_stem', copies( '0', 5 - length( num ) ) || num, 'UNIQUE' )
-
- end
-
- call EMS_Sort_Stem( 'glob_stem' )
-
- do i=1 to glob_stem.0
-
- glob_stem.i = cfg_name || '.' || Extract_Num( glob_stem.i )
-
- end
-
- return 0
-
-
-
- Extract_Num: procedure
-
- parse arg num
-
- do while left( num, 1 ) = '0'
-
- num = delstr( num, 1, 1 )
-
- end
-
- if num = '' then num = 0
-
- return num
-
-
-
- Group_Hash: procedure
-
- parse arg name , level
-
- return name || '/' || copies( '0', 5 - length( level ) ) || level
-
-
-
- Choose_Node: procedure EXPOSE nodes.
-
- sel = -1
- res = EMS_Do_Choice_Single( 'Pick up a node', 'nodes', 'sel' )
-
- if res ~= 'OK' then return ''
-
- return nodes.sel
-
-
-
- Choose_Area: procedure EXPOSE areas.
-
- sel = -1
- res = EMS_Do_Choice_Single( 'Pick up an area', 'areas', 'sel' )
-
- if res ~= 'OK' then return ''
-
- return areas.sel
-
-
-
- Ask_UseGroups: procedure
-
- res = EMS_Do_Request( 'Should I Use Groups To Limit' || 'A'X || ' Visibility Of Areas? ', 'YES|NO' )
-
- if res = 'YES' then return 1
-
- return 0
-