/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX __VXREXX____APPENDS__ */ __VXREXX____APPENDS__: /* #append U:\Develop\Samba\trunk\guitools\shared\inittempdir.vrs #append U:\VXREXX\Shared\nlv.vrs */ return /*:VRX _ContainersInit */ _ContainersInit: call _DebugLog '_ContainersInit() started' CN_HOSTS_STATUS_FH = VRMethod("CN_HOSTS","AddField","Icon", NLVGetMessage(30)) CN_HOSTS_IP_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(31)) CN_HOSTS_PIP_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(32)) CN_HOSTS_NAME_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(33)) CN_HOSTS_ANSWER_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(34)) CN_HOSTS_DELAY_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(35)) CN_HOSTS_LOSS_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(36)) CN_HOSTS_PACKETS_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(37)) CN_HOSTS_MAC_FH = VRMethod("CN_HOSTS","AddField","String",NLVGetMessage(39)) ok = VRMethod("CN_HOSTS", "SetFieldAttr", CN_HOSTS_IP_FH, "Visible", 0) ok = VRMethod("CN_HOSTS", "SetFieldAttr", CN_HOSTS_ANSWER_FH, "Visible", 0) ok = VRMethod("CN_HOSTS", "SetFieldAttr", CN_HOSTS_Packets_FH, "Visible", 0) ok = VRMethod("CN_HOSTS", "SetFieldAttr", CN_HOSTS_DELAY_FH, "ReadOnly", 1) ok = VRMethod("CN_HOSTS", "SetFieldAttr", CN_HOSTS_LOSS_FH, "ReadOnly", 1) ok = VRSet("CN_HOSTS", "DetailSort", CN_HOSTS_IP_FH) call _DebugLog '_ContainersInit() done' return /*:VRX _DebugLog */ _DebugLog: IF options.!debug <> 1 THEN return debugline = strip(arg(1)) if pos('=',debugline) > 0 then do parse var debugline debl '=' debr debl = strip(debl) debr = strip(debr) debr = strip(debr,,'"') debugline = left(debl,(max(20,length(debl))))' = "'debr'"' end if pos("started", debugline) > 0 |, pos("aborted", debugline) > 0 |, pos("done", debugline) > 0 then say time()' 'debugline else say ' 'debugline return /*:VRX _EnvInit */ _EnvInit: call _DebugLog "_EnvInit() started." ETC = Value("ETC",,"OS2ENVIRONMENT") call _DebugLog '%ETC% = "'ETC'"' PingHostLst = ETC||'\PingHost.LSt' call _DebugLog 'PingHost.Lst = "'PingHostLst'"' HOSTSFile = ETC||'\HOSTS' call _DebugLog 'Hosts = "'HOSTSFILE'"' MACCacheFile = ETC||'\MAC.Cache' call _DebugLog 'MACCache = "'MACCacheFile'"' call _DebugLog "_EnvInit() done." return /*:VRX _ExplorePing */ _ExplorePing: call _debuglog "_ExplorePing() started" call _MACCacheRead ok = VRMethod("CN_HOSTS","GetRecordList","ALL","hosts.") if hosts.0 = 0 then do buttons.0 = 2 default = 1 buttons.default = "Ok" esc = 2 buttons.esc = "Cancel" IP = "192.168.1.255" response = VRPrompt( VRWindow(), , "Please enter your name:", , "IP", , "Inquiry...", , "buttons.", , default, , esc ) end else IP = VRMethod("CN_HOSTS","GetFieldData",hosts.1, CN_HOSTS_IP_FH) lpos = lastpos('.',IP) SubNet = left(IP,lpos) call VRSet "SW_PROGRESS", "Visible", 1 Stopped = 0 ok = VRSet("ICB_STARTSTOP","PicturePath", "$2") do J = 1 to 254 CurIP = SubNet||right('00'J,3) ok = VRset("SW_PROGRESS","HintText","Testing IP "_pureIP(CurIP)) Prog = 100 * right(CurIP,3) % 254 ok = VRSet("PRO_EXPLORE","Percent", Prog ) call _pinghost _pureIP(CurIP) if strip(loss) = "0%" then do Found = 0 do I = 1 to hosts.0 IP = VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_IP_FH) if IP = CurIP then do ok = VRMethod("CN_HOSTS","SetRecordAttr",hosts.I, "Selected", 1) ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'Yes') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$5') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_DELAY_FH, stats' ms') Found = 1 if NsLookUp = 1 then do resolvedname = _ResolveName(CurIP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end leave end end if Found = 0 then do call _debuglog "Unknown host found" RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_IP_FH, CurIP, CN_HOSTS_NAME_FH, "(unknown)") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, _pureIP(CurIP)) ok = VRMethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_STATUS_FH, '$7') ok = VRMethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_DELAY_FH, stats' ms') if NsLookUp = 1 then do resolvedname = _ResolveName(CurIP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end end end EventString = VREvent('N') if EventString <> 'nop' & EventString <> "CALL TM_PING_Trigger" then do call _debuglog EventString interpret Eventstring end if Stopped = 1 then leave end ok = VRMethod("CN_HOSTS","SortRecords") call VRSet "SW_PROGRESS", "Visible", 0 call _MACCacheWrite call _debuglog "_ExplorePing() done" return /*:VRX _FastPing */ _FastPing: procedure expose fasthosts. FastIP = arg(1) pingout = SysTempFileName(TempDir||'fasthosts???') lpos = lastpos('.',FastIP) SubNet = left(FastIP,lpos)'255' call _debuglog "Subnet ="Subnet address cmd 'detach ping 'SubNet' 24 1 2>NUL 1>'pingout call VRSet VRWindow(), 'Pointer', 'Wait' ok = RxNap(1100) status = stream(pingout,'c','open read') do while pos("NOT",status) > 0 ok = RxNap(200) status = stream(pingout,'c','open read') call _debuglog "Status ="status end call VRSet VRWindow(), 'Pointer', '' I = 0 do while lines(pingout) > 0 pingline = linein(pingout) if pos("from",pingline) = 0 then iterate I = I + 1 parse var pingline . 'from ' IP ':' . 'time='ms'.' . IP = _sortableIP(IP) call _debuglog "IP="IP fasthosts.I = IP' 'ms end fasthosts.0 = I call _debuglog "FastHosts="I ok = stream(pingout,'c','close') ok = SysFileDelete(pingout) return /*:VRX _GetMAC */ _GetMAC: procedure expose options. TempDir MacCache. CurIP = _pureIP(arg(1)) cached = arg(2) call _debuglog "_GetMAC("CurIP") started." call _debuglog "cached ="cached call _debuglog "MacCache.0 = "MacCache.0 if datatype(MacCache.0) <> "NUM" then do MACCache. = "" MACCache.0 = 0 end if cached = "" then do arpout = SysTempFileName(TempDir'arpout.???') address cmd 'arp 'CurIP' >'arpout dummy = linein(arpout) dummy = linein(arpout) dummy = linein(arpout) dummy = linein(arpout) arpline = linein(arpout) call _debuglog "arpline="arpline end if (pos('no entry',arpline) > 0 | pos('incomplete',arpline) > 0| cached = "cached")then do call _debuglog "MAC cache search" MAC = "" do I = 1 to MacCache.0 parse var MacCache.I MCIP' 'MCMAC if MCIP = CurIP then do call _debuglog "MAC cache hit "MCMAC" for "MCIP MAC = MCMAC leave end end if MAC = "" then call _debuglog "MAC cache miss for "MCIP end else do MAC = substr(arpline,14,17) AA = right('0'||strip(SUBSTR(MAC,1,2)),2) BB = right('0'||strip(SUBSTR(MAC,4,2)),2) CC = right('0'||strip(SUBSTR(MAC,7,2)),2) DD = right('0'||strip(SUBSTR(MAC,10,2)),2) EE = right('0'||strip(SUBSTR(MAC,13,2)),2) FF = right('0'||strip(SUBSTR(MAC,16,2)),2) MAC = translate(AA':'BB':'CC':'DD':'EE':'FF) end ok = stream(arpout,'c','close') ok = SysFileDelete(arpout) call _debuglog "_GetMAC() done, "MAC return MAC /*:VRX _GUIInit */ _GUIInit: call _DebugLog "_GUIInit() started." if options.!debug = 0 then ok = VRRedirectStdIO("OFF") else ok = VRRedirectStdIO("ON") if datatype(Top) = 'NUM' then do ok = VRset("Main","Top",Top) ok = VRset("Main","Left",Left) ok = VRset("Main","Width",Width) ok = VRset("Main","Height",Height) end ok = VRSet("CN_HOSTS","Font", Font) ok = VRSet("TM_PING","Delay",Intervall) /* Common margin around controls */ margin = ((VRGet("Main", "InteriorLeft") / 3) * 2) + 2 call VRSet 'ICB_STARTSTOP', 'Hinttext', NLVGetMessage(40) call VRSet 'ICB_EXPLORE', 'Hinttext', NLVGetMessage(41) call VRSet 'ICB_SAVE', 'Hinttext', NLVGetMessage(42) call VRSet 'ICB_IMPORT', 'Hinttext', NLVGetMessage(43) call VRSet 'ICB_SETTINGS', 'Hinttext', NLVGetMessage(44) call VRSet 'ICB_HELP', 'Hinttext', NLVGetMessage(45) call VRSet 'ICB_QUIT', 'Hinttext', NLVGetMessage(46) call VRSet 'ICB_REFRESH', 'Hinttext', NLVGetMessage(47) call VRSet 'ICB_ADD', 'Hinttext', NLVGetMessage(48) call VRSet 'ICB_REMOVE', 'Hinttext', NLVGetMessage(49) call VRSet 'ICB_WOL', 'Hinttext', NLVGetMessage(68) call VRSet 'ICB_RESET', 'Hinttext', NLVGetMessage(50) call _DebugLog "_GUIInit() done." return /*:VRX _help */ _help: address cmd "view pmping.hlp" return /*:VRX _ImportHosts */ _ImportHosts: call _DebugLog "_ImportHosts() started" ResetCN = 1 do while lines(HostsFile) > 0 if ResetCN = 1 then do ok = VRMethod("CN_HOSTS","RemoveRecord","ALL") ResetCN = 0 end hostline = linein(HostsFile) if left(strip(hostline),1) = "#" then iterate parse var hostline IP NameDomain Name Comment if _pureIP(IP) = "127.0.0.1" then iterate RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, IP) IP = _sortableIP(IP) ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_IP_FH, IP, CN_HOSTS_NAME_FH, Name) ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_MAC_FH, IP, CN_HOSTS_MAC_FH, _GetMAC(IP,"cached")) end ok = stream(HostsFile,'c','close') Msg.Type = "I" Msg.Text = "List of hosts imported from "HostsFile call _ShowMsg call _DebugLog "_ImportHosts() done" return /*:VRX _INIRead */ _INIRead: call _debuglog '_INIRead() started' OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\PMPING.INI',,'\') ok = SysFileTree(OurINI, INIFound.,'FO') if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE') call _debuglog 'INI file = "'OurINI'"' Top = VRGetIni( "BWWPing", "PosTop", OurINI , 'NoClose') Left = VRGetIni( "BWWPing", "PosLeft", OurINI , 'NoClose') Width = VRGetIni( "BWWPing", "PosWidth", OurINI , 'NoClose') Height= VRGetIni( "BWWPing", "PosHeight", OurINI , 'NoClose') Intervall = VRGetIni( "BWWPing", "Intervall", OurINI , 'NoClose') if datatype(Intervall) <> "NUM" then Intervall = 30000 Stopped = VRGetIni( "BWWPing", "Stopped", OurINI , 'NoClose') if datatype(Stopped) <> "NUM" then Stopped = 1 FastPing = VRGetIni( "BWWPing", "FastPing", OurINI , 'NoClose') if datatype(FastPing) <> "NUM" then FastPing = 0 FastHosts.0 = 0 SavePassive = VRGetIni( "BWWPing", "SavePassive", OurINI , 'NoClose') if datatype(SavePassive) <> "NUM" then SavePassive = 1 SaveHosts = VRGetIni( "BWWPing", "SaveHosts", OurINI , 'NoClose') if datatype(SaveHosts) <> "NUM" then SaveHosts = 0 NsLookUp = VRGetIni( "BWWPing", "NsLookUp", OurINI , 'NoClose') if datatype(NsLookUp) <> "NUM" then NsLookUp = 0 Font = VRGetIni( "BWWPing", "Font", OurINI , 'NoClose') if Font = "" then Font = "9.WarpSans" options.!debug = VRGetIni( "BWWPing", "Debug", OurINI , 'NoClose') if datatype(options.!debug) <> "NUM" then options.!debug = 0 call _debuglog '_INIRead() done' return /*:VRX _INIWrite */ _INIWrite: call _debuglog "_INIWrite() started" ok = VRSetIni( "BWWPing", "PosTop", VRGet("Main","Top"), OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "PosLeft", VRGet("Main","Left"), OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "PosWidth", VRGet("Main","Width"), OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "PosHeight", VRGet("Main","Height"), OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "Intervall", VRGet("TM_PING","Delay"), OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "Font", VRGet("CN_HOSTS","Font"), OurINI ,'NoClose') ok = VRSetIni( "BWWPing", "Stopped", Stopped, OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "FastPing", FastPing, OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "SavePassive", SavePassive, OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "SaveHosts", SaveHosts, OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "NsLookUp", NsLookUp, OurINI, 'NoClose') ok = VRSetIni( "BWWPing", "Debug", options.!debug, OurINI, 'NoClose') call _debuglog "_INIWrite() done" return /*:VRX _LoadOtherFuncs */ _LoadOtherFuncs: call _debuglog "_LoadOtherFuncs() started" ok = RxFuncAdd( 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs') call _debuglog "RXFuncAdd SysLoadFuncs RC = "OK ok = SysLoadFuncs() call _debuglog "SysLoadFuncs RC = "OK ok = RxFuncAdd( 'VRXLoadFuncs', 'VROBJEX', 'VRXLoadFuncs') call _debuglog "RXFuncAdd VRXLoadFuncs RC = "OK ok = VRXLoadFuncs() call _debuglog "VRXLoadFuncs RC = "OK ok = RxFuncAdd('RxExtra', 'RxExtras', 'RxExtra') call _debuglog "RXFuncAdd RxExtras RC = "OK ok = RxExtra('Load') call _debuglog "RXExtra Load RC = "OK ok = RxFuncAdd( 'SockLoadFuncs', 'rxsock', 'SockLoadFuncs') call _debuglog "RXFuncAdd SockLoadFuncs RC = "OK ok = SockLoadFuncs('*') call _debuglog "SockLoadFuncs Load RC = "OK call _debuglog "_LoadOtherFuncs() done" return /*:VRX _MACCacheRead */ _MACCacheRead: call file2stem MacCacheFile, "MacCache.", "NODEL" return /*:VRX _MACCacheWrite */ _MACCacheWrite: call _debuglog "MACCacheWrite() started" ok = VRMethod("CN_HOSTS","GetRecordList","ALL","hosts.") ok = SysFileDelete(MACCacheFile) call _debuglog "Delete MACCache RC="ok call lineout MACCacheFile, "# "NLVGetMessage(1)" on "date()" "time() do I = 1 to hosts.0 IP = strip(VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_PIP_FH)) MAC = strip(VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_MAC_FH)) macline = IP' 'MAC if MAC <> "" then do call _debuglog MacLine call lineout MACCacheFile, MACLine end end ok = Stream(MACCacheFile,'c','close') call _debuglog "_MACCacheFileWrite done" return /*:VRX _NLVSetup */ _NLVSetup: settings.!messages = 1 /* language files exist(s) */ settings.!helpfile = 0 /* helpfiles do not exist */ settings.!nlv8dot3 = 0 /* NLV may have long filenames */ call NLVSetup Msg.Title = NLVGetMessage(1) ok = VRset("Main","Caption",NLVGetMessage(1)) ok = VRset("Main","HintText",NLVGetMessage(1)' - 'NLVGetMessage(59)) CALL NLVSetText 'Menu_File', 'Caption', 16 CALL NLVSetText 'Menu_File_Save', 'Caption', 12 CALL NLVSetText 'Menu_File_Import', 'Caption', 38 CALL NLVSetText 'Menu_File_exit', 'Caption', 10 CALL NLVSetText 'Menu_Actions', 'Caption', 17 CALL NLVSetText 'Menu_Actions_StartStop','Caption', 15 CALL NLVSetText 'Menu_Actions_Explore', 'Caption', 62 CALL NLVSetText 'Menu_Actions_WOL', 'Caption', 67 CALL NLVSetText 'Menu_Actions_Add', 'Caption', 63 CALL NLVSetText 'Menu_Actions_Remove', 'Caption', 64 CALL NLVSetText 'Menu_Actions_Refresh', 'Caption', 65 CALL NLVSetText 'Menu_Actions_Reset', 'Caption', 66 CALL NLVSetText 'Menu_Settings', 'Caption', 19 CALL NLVSetText 'Menu_Help', 'Caption', 18 return /*:VRX _PingHost */ _PingHost: call _debuglog "_PingHost() started" IpAddr = arg(1) call _debuglog "IP="IpAddr pingout = SysTempFileName(TempDir||'BWWPING.???') address cmd 'detach ping 'IPaddr' 24 1 2>NUL 1>'pingout call VRSet VRWindow(), 'Pointer', 'Wait' ok = RxNap(1100) status = stream(pingout,'c','open read') do while pos("NOT",status) > 0 ok = RxNap(200) status = stream(pingout,'c','open read') call _debuglog "Status="status end call VRSet VRWindow(), 'Pointer', '' do while lines(pingout) > 0 pingline = linein(pingout) if pos('----',pingline) > 0 then do pingline = linein(pingout) parse var pingline transm ' packets transmitted, ' recvd 'packets received, 'loss . pingline = linein(pingout) parse var pingline . ' = ' stats end end ok = stream(pingout,'c','close') ok = SysFileDelete(pingout) EventString = VREvent('N') if EventString <> 'nop' & EventString <> "CALL TM_PING_Trigger" then do call _debuglog EventString interpret Eventstring end call _debuglog "_PingHost() done" return /*:VRX _PingHostLstRead */ _PingHostLstRead: call _DebugLog "_PingHostLstRead() started" do while lines(PingHostLst) > 0 hostline = linein(PingHostLst) if left(strip(hostline),1) = "#" then iterate parse var hostline IP Name IP = strip(IP) name = strip(name) RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, IP) IP = _sortableIP(IP) ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_IP_FH, IP, CN_HOSTS_NAME_FH, Name) ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_MAC_FH, IP, CN_HOSTS_MAC_FH, _GetMAC(IP,"cached")) end ok = stream(PingHostLst,'c','close') call _DebugLog "_PingHostLstRead() done" return /*:VRX _PingHostLstWrite */ _PingHostLstWrite: call _debuglog "_PingHostLstWrite started" ok = VRMethod("CN_HOSTS","GetRecordList","ALL","hosts.") ok = SysFileDelete(PingHostLst) call _debuglog "Delete PingHosts RC="ok if SaveHosts = 1 then do ok = SysFileDelete(HostsFile) call _debuglog "Delete Hosts RC="ok end call _debuglog "SavePassive = "SavePassive call _debuglog "SaveHosts = "SaveHOsts call lineout PingHostLst, "# "NLVGetMessage(1)" on "date()" "time() if SaveHosts = 1 then do call lineout HostsFile, "# "NLVGetMessage(1)" on "date()" "time() call lineout HostsFile, left("# IP-Adress",17)||left("Name.domain",30) ||left("Name",18)|| "Comment" call lineout HostsFile, left("127.0.0.1",17)||left("localhost.localdomain",30)||left("localhost",18)||"# Loopback interface" end do I = 1 to hosts.0 IP = strip(VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_PIP_FH)) Name = strip(VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_Name_FH)) Answer = strip(VRMethod("CN_HOSTS","GetFieldData",hosts.I,CN_HOSTS_ANSWER_FH)) hostline = IP' 'Name if SavePassive = 1 then do call lineout PingHostLst, Hostline if SaveHosts = 1 then do call lineout HostsFile, left(IP,17)||left(Name,30)||left(Name,18)||"# "Name end end else do If Answer = "Yes" then do call lineout PingHostLst, Hostline if SaveHosts = 1 then do call lineout HostsFile, left(IP,17)||left(Name,30)||left(Name,18)||"# "Name end end end end ok = Stream(PingHostLst,'c','close') if SaveHosts = 1 then ok = Stream(HostsFile,'c','close') Msg.Type = "I" if SaveHosts = 1 then do Msg.Text = NLVGetMessage(60)" "PingHostLst", "HostsFile end else Msg.Text = NLVGetMessage(60)" "PingHostLst Msg.Type = "I" call _ShowMsg if SaveHosts = 1 then do call _debuglog NLVGetMessage(60)" "PingHostLst", "Hostsfile end call _debuglog "_PingHostLstWrite done" return /*:VRX _pureIP */ _pureIP: procedure IP = arg(1) parse var IP P1'.'P2'.'P3'.'P4 P1= strip(P1,"L","0") if P1 = '' then P1 = "0" P2= strip(P2,"L","0") if P2 = '' then P2 = "0" P3= strip(P3,"L","0") if P3 = '' then P3 = "0" P4= strip(P4,"L","0") if P4 = '' then P4 = "0" return P1'.'P2'.'P3'.'P4 /*:VRX _ResolveName */ _ResolveName: procedure expose TempDir options. call _debuglog "_ResolveName("arg(1)") started" CurIP = arg(1) nslookupout = SysTempFileName(TempDir||'BWWPING.???') nslookuperr = SysTempFileName(TempDir||'BWWPINGERR.???') call _debuglog 'nslookup '_pureIP(CurIP)' 2>'nslookuperr' 1>'nslookupout address cmd 'nslookup '_pureIP(CurIP)' 2>'nslookuperr' 1>'nslookupout dummy = linein(nslookupout) dummy = linein(nslookupout) dummy = linein(nslookupout) name = linein(nslookupout) parse var name . ':' name name = strip(name) nsIP = linein(nslookupout) parse var nsIP . ':' nsIP nsIP = strip(nsIP) ok = stream(nslookupout,'c','close') ok = SysFileDelete(nslookupout) if nsIP <> _pureIP(CurIP) then do /* FIXME: Error Message (box?) */ errline = linein(nslookuperr) call _debuglog errline name = "error" ok = stream(nslookuperr,'c','close') ok = SysFileDelete(nslookuperr) end call _debuglog "_ResolveName() done, "name return name /*:VRX _SetButtonPos */ _SetButtonPos: procedure expose margin pbtnwd btnID = arg(1) btnNr = arg(2) ok = VRSet(btnID,"Left", margin * btnNr + pbtnwd * (btnNr-1)) ok = VRSet(btnID,"Top", margin) ok = VRSet(btnID,"Height", pbtnwd) ok = VRSet(btnID,"Width", pbtnwd) return /*:VRX _ShowMsg */ _ShowMsg: Buttons.1 = NLVGetMessage(2) Buttons.0 = 1 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) return /*:VRX _SortableIP */ _SortableIP: procedure IP = arg(1) parse var IP P1'.'P2'.'P3'.'P4 P1= right("000"||P1,3) P2= right("000"||P2,3) P3= right("000"||P3,3) P4= right("000"||P4,3) return P1'.'P2'.'P3'.'P4 /*:VRX file2stem */ file2stem: call _debuglog 'file2stem() started' msgfile = arg(1) /* file to create stem of */ msgstem = arg(2) /* name of the stem */ if right(msgstem,1) <> '.' then msgstem = msgstem'.' delmsgfile = translate(arg(3)) /* erase file after transfer */ skipwords = strip(arg(4)||' creating lame tdb( ***') /* skip lines with these words */ do J = 1 to words(skipwords) skip.J = translate(word(skipWords,J)) end skip.0 = J say ' file2stem("'msgfile'","'msgstem'")' dyn = 'drop 'msgstem interpret dyn stemcount = 0 skipped = 0 do while lines(msgfile) > 0 stemcount = stemcount + 1 inline = linein(msgfile) SkipIt = 0 do J = 1 to skip.0 if pos(skip.J,translate(inline)) > 0 then do skipit = 1 stemcount = stemcount - 1 skipped = skipped + 1 leave end end if \SkipIt then do dyn = msgstem||stemcount' = inline' interpret dyn end end dyn = msgstem||"0 = "stemcount interpret dyn ok = stream(msgfile,'c','close') if delMsgFile <> "NODEL" then ok = SysFileDelete(msgfile) drop msgfile msgstem call _debuglog 'file2stem() ['stemcount' added, 'skipped' skipped] done' return stemcount /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX ICB_ADD_Click */ ICB_ADD_Click: RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, '0.0.0.0', CN_HOSTS_NAME_FH, "?") ok = VRMethod("CN_HOSTS","SetRecordAttr",RH, "Selected", 1) return /*:VRX ICB_EXPLORE_Click */ ICB_EXPLORE_Click: call _explorePing return /*:VRX ICB_HELP_Click */ ICB_HELP_Click: call _help return /*:VRX ICB_IMPORT_Click */ ICB_IMPORT_Click: call _ImportHosts return /*:VRX ICB_QUIT_Click */ ICB_QUIT_Click: call Main_Close return /*:VRX ICB_REFRESH_Click */ ICB_REFRESH_Click: ok = VRMethod("CN_HOSTS","RemoveRecord","ALL") call _pinghostlstread return /*:VRX ICB_REMOVE_Click */ ICB_REMOVE_Click: ok = VRMethod("CN_HOSTS","GetRecordList","Selected","hosts.") do I = 1 to hosts.0 ok = VRMethod("CN_HOSTS","RemoveRecord",hosts.I) end return /*:VRX ICB_RESET_Click */ ICB_RESET_Click: ok = VRMethod("CN_HOSTS","RemoveRecord","ALL") return /*:VRX ICB_SAVE_Click */ ICB_SAVE_Click: call _PingHostLstWrite return /*:VRX ICB_SETTINGS_Click */ ICB_SETTINGS_Click: if Stopped = 0 then do call ICB_STARTSTOP_Click end window = VRLoadSecondary( "SW_SETTINGS" ) return /*:VRX ICB_STARTSTOP_Click */ ICB_STARTSTOP_Click: if Stopped = 0 then do /* stop it */ ok = VRSet("TM_Ping","Enabled",0) Stopped = 1 ok = VRSet("ICB_STARTSTOP","PicturePath", "$3") end else do /* start it */ ok = VRSet("TM_Ping","Enabled",1) Stopped = 0 ok = VRSet("ICB_STARTSTOP","PicturePath", "$2") call TM_PING_Trigger end return /*:VRX ICB_WOL_Click */ ICB_WOL_Click: call _debuglog "ICB_WOL_Click() started" ok = VRMethod("CN_HOSTS","GetRecordList","Selected","hosts.") do I = 1 to hosts.0 MAC = VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_MAC_FH ) if MAC <> "" then do AA = X2C(SUBSTR(MAC,1,2)); BB = X2C(SUBSTR(MAC,4,2)); CC = X2C(SUBSTR(MAC,7,2)); DD = X2C(SUBSTR(MAC,10,2)); EE = X2C(SUBSTR(MAC,13,2)); FF = X2C(SUBSTR(MAC,16,2)); X = AA||BB||CC||DD||EE||FF; SCT = SockSocket('AF_INET', 'SOCK_DGRAM', 'IPPROTO_UDP'); RC = SockSetSockOpt(SCT, 'SOL_SOCKET', 'SO_BROADCAST', '1'); RC = SockIOCtl(SCT, 'FIONBIO', '0'); adr.!family = 'AF_INET'; adr.!addr = '255.255.255.255'; adr.!port = 9; S = COPIES(D2C(255) ,6); T = COPIES(X ,16); G = COPIES(D2C(0) ,6); RC = SockConnect(SCT, "adr.!"); STG = S||T||G; call _debuglog STG; call _debuglog '"'C2X(S)'"'; call _debuglog '"'C2X(X)'" x 16'; call _debuglog '"'C2X(G)'"'; RC = SockSend(SCT, STG); call SockSoClose SCT; Msg.Text = NLVGetMessage(67)': 'VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_PIP_FH )' ('VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_NAME_FH )', 'MAC')' Msg.Type = "I" end else do Msg.Text = NLVGetMessage(69) Msg.Type = "E" end call _showmsg end call _debuglog "ICB_WOL_Click() done" return /*:VRX Init */ Init: window = VRWindow() call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window return /*:VRX Main_Close */ Main_Close: call _INIWrite Stopped = 1 ok = VRSet("ICB_STARTSTOP","PicturePath", "$3") ok = SysFileTree(TempDir||'BWWPING*',tmps.,'FO') do I = 1 to tmps.0 ok = SysFileDelete(tmps.I) end call Quit return /*:VRX Main_Create */ Main_Create: options.!debug = 0 ok = VRSet("Main","Visible", options.!debug) if options.!debug = 0 then ok = VRRedirectStdIO("OFF") call _LoadOtherFuncs call _InitTempDir call _EnvInit call _INIRead call _NLVSetup call _GUIInit call _ContainersInit call _MACCacheRead call _PingHostLstRead call Main_ToolTips call Main_Resize ok = VRSet("Main","Visible", 1) window = VRLoadSecondary( "SW_PROGRESS" ) /* resume if closed running */ if Stopped = 0 then do ok = VRSet("TM_Ping","Enabled",1) ok = VRSet("ICB_STARTSTOP","PicturePath", "$2") call TM_PING_Trigger end return /*:VRX Main_Resize */ Main_Resize: call _Debuglog 'Main_Resize started' ok = VRSet("Main","Painting", 0) /* Basic measurements */ main_iwidth = VRGet("Main","InteriorWidth") /* Width of window client-area */ main_iheight = VRGet("Main","InteriorHeight") /* Height of window client-area */ sbar_height = margin * 10 /* Height of status-bar */ marginx2 = margin * 2 /* Common margin around controls */ marginx4 = margin * 4 pbtnwd = VRGet("GB_Toolbar","Height") - marginx2 ok = VRSet("GB_Toolbar","Left", margin) ok = VRSet("GB_Toolbar","Top", margin) ok = VRSet("GB_Toolbar","Height", margin * 20) ok = VRSet("GB_Toolbar","Width", main_iwidth - marginx2) ok = VRSet("CN_HOSTS","Left", margin) ok = VRSet("CN_HOSTS","Top", VRGet("GB_Toolbar", "Height") + marginx2) ok = VRSet("CN_HOSTS","Height", main_iheight - VRGet("GB_Toolbar", "Height") - marginx2) ok = VRSet("CN_HOSTS","Width", main_iwidth - marginx2) call _SetButtonPos "ICB_STARTSTOP", 1 call _SetButtonPos "ICB_EXPLORE", 2 call _SetButtonPos "ICB_SAVE", 3 call _SetButtonPos "ICB_REFRESH", 4 call _SetButtonPos "ICB_ADD", 5 call _SetButtonPos "ICB_REMOVE", 6 call _SetButtonPos "ICB_WOL", 7 call _SetButtonPos "ICB_RESET", 8 call _SetButtonPos "ICB_IMPORT", 9 call _SetButtonPos "ICB_SETTINGS", 10 call _SetButtonPos "ICB_HELP", 11 call _SetButtonPos "ICB_QUIT",12 /* check and empty event queue, trash spurious resize events */ EventString = '' TrashedResize = 0 do until EventString = 'nop' EventString = VREvent('N') if EventString <> 'nop' then do if EventString = 'CALL Main_Resize' then TrashedResize = 1 else interpret eventString end end if TrashedResize then CALL Main_Resize ok = VRSet("Main", "Painting", 1) call _Debuglog 'Main_Resize done' return /*:VRX Main_ToolTips */ Main_ToolTips: CALL VRMethod 'TT_Main', 'Register', 'ICB_STARTSTOP', NLVGetMessage(40) CALL VRMethod 'TT_Main', 'Register', 'ICB_EXPLORE', NLVGetMessage(41) CALL VRMethod 'TT_Main', 'Register', 'ICB_SAVE', NLVGetMessage(42) CALL VRMethod 'TT_Main', 'Register', 'ICB_IMPORT', NLVGetMessage(43) CALL VRMethod 'TT_Main', 'Register', 'ICB_SETTINGS', NLVGetMessage(44) CALL VRMethod 'TT_Main', 'Register', 'ICB_HELP', NLVGetMessage(45) CALL VRMethod 'TT_Main', 'Register', 'ICB_QUIT', NLVGetMessage(46) CALL VRMethod 'TT_Main', 'Register', 'ICB_REFRESH', NLVGetMessage(47) CALL VRMethod 'TT_Main', 'Register', 'ICB_ADD', NLVGetMessage(48) CALL VRMethod 'TT_Main', 'Register', 'ICB_REMOVE', NLVGetMessage(49) CALL VRMethod 'TT_Main', 'Register', 'ICB_WOL', NLVGetMessage(68) CALL VRMethod 'TT_Main', 'Register', 'ICB_RESET', NLVGetMessage(50) return /*:VRX Menu_Actions_Add_Click */ Menu_Actions_Add_Click: RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, '0.0.0.0', CN_HOSTS_NAME_FH, "?") ok = VRMethod("CN_HOSTS","SetRecordAttr",RH, "Selected", 1) return /*:VRX Menu_Actions_Explore_Click */ Menu_Actions_Explore_Click: call _explorePing return /*:VRX Menu_Actions_Refresh_Click */ Menu_Actions_Refresh_Click: ok = VRMethod("CN_HOSTS","RemoveRecord","ALL") call _pinghostlstread return /*:VRX Menu_Actions_Remove_Click */ Menu_Actions_Remove_Click: ok = VRMethod("CN_HOSTS","GetRecordList","Selected","hosts.") do I = 1 to hosts.0 ok = VRMethod("CN_HOSTS","RemoveRecord",hosts.I) end return /*:VRX Menu_Actions_Reset_Click */ Menu_Actions_Reset_Click: ok = VRMethod("CN_HOSTS","RemoveRecord","ALL") return /*:VRX Menu_Actions_StartStop_Click */ Menu_Actions_StartStop_Click: if Stopped = 0 then do /* stop it */ ok = VRSet("TM_Ping","Enabled",0) Stopped = 1 ok = VRSet("ICB_STARTSTOP","PicturePath", "$3") end else do /* start it */ ok = VRSet("TM_Ping","Enabled",1) Stopped = 0 ok = VRSet("ICB_STARTSTOP","PicturePath", "$2") call TM_PING_Trigger end return /*:VRX Menu_Actions_WOL_Click */ Menu_Actions_WOL_Click: call ICB_WOL_Click return /*:VRX Menu_File_Exit_Click */ Menu_File_Exit_Click: call Main_Close return /*:VRX Menu_File_Import_Click */ Menu_File_Import_Click: call _ImportHosts return /*:VRX Menu_File_Save_Click */ Menu_File_Save_Click: call _PingHostLstWrite return /*:VRX Menu_Help_Click */ Menu_Help_Click: call _help return /*:VRX Menu_Settings_Click */ Menu_Settings_Click: if Stopped = 0 then do call ICB_STARTSTOP_Click end window = VRLoadSecondary( "SW_SETTINGS" ) return /*:VRX PB_SETTINGS_CANCEL_Click */ PB_SETTINGS_CANCEL_Click: call SW_SETTINGS_Close return /*:VRX PB_Settings_OK_Click */ PB_Settings_OK_Click: Intervall = VRGet("SPIN_Intervall","Value") * 1000 ok = VRSet("TM_PING","Delay", Intervall) FastPing = VRGet("CB_FASTPING","Set") SavePassive = VRGet("CB_SAVEPASSIVE","Set") SaveHosts = VRGet("CB_SAVEHosts","Set") NsLookup = VRGet("CB_NSLOOKUP","Set") options.!debug = VRGet("CB_DEBUG","Set") if options.!debug = 0 then ok = VRRedirectStdIO("OFF") else ok = VRRedirectStdIO("ON") call SW_SETTINGS_Close return /*:VRX Quit */ Quit: window = VRWindow() call VRSet window, "Shutdown", 1 drop window return /*:VRX SW_ABOUT_Close */ SW_ABOUT_Close: call SW_ABOUT_Fini return /*:VRX SW_ABOUT_Create */ SW_ABOUT_Create: call SW_ABOUT_Init call VRSet 'SW_ABOUT', 'Caption', NLVGetMessage(22) call VRSet 'DT_ABOUT_PROGRAM','Caption', NLVGetMessage(1)' 'NLVGetMessage(61)' 'VRGet("Main","Userdata") call VRSet 'DT_ABOUT', 'Caption', NLVGetMessage(57) call VRSet 'DT_ABOUT_ICONS', 'Caption', NLVGetMessage(58) return /*:VRX SW_ABOUT_Fini */ SW_ABOUT_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_ABOUT_Init */ SW_ABOUT_Init: window = VRInfo( "Object" ) drop window return /*:VRX SW_HOSTS_Close */ SW_HOSTS_Close: call SW_HOSTS_Fini return /*:VRX SW_HOSTS_Create */ SW_HOSTS_Create: call SW_HOSTS_Init call VRSet 'SW_HOSTS', 'Caption', NLVGetMessage(21) call VRSet 'SW_HOSTS', 'Font', VRGet("CN_HOSTS","Font") call VRSet "CB_FASTPING", "Caption", NLVGetMessage(27) call VRSet "CB_SAVEPASSIVE","Caption", NLVGetMessage(25) call VRSet "CB_SAVEHOSTS", "Caption", NLVGetMessage(26) call VRSet "CB_NSLOOKUP", "Caption", NLVGetMessage(28) CALL VRMethod 'TT_HOSTS', 'Register', "CB_FASTPING", NLVGetMessage(53) CALL VRMethod 'TT_HOSTS', 'Register', "CB_SAVEPASSIVE", NLVGetMessage(52) CALL VRMethod 'TT_HOSTS', 'Register', "CB_SAVEHOSTS", NLVGetMessage(51) CALL VRMethod 'TT_HOSTS', 'Register', "CB_NSLOOKUP", NLVGetMessage(54) ok = VRSet("CB_FASTPING", "Set", FastPing) ok = VRSet("CB_SAVEPASSIVE","Set", SAVEPASSIVE) ok = VRSet("CB_SAVEHOSTS", "Set", SAVEHOSTS) ok = VRSet("CB_NSLOOKUP", "Set", NSLOOKUP) return /*:VRX SW_HOSTS_Fini */ SW_HOSTS_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_HOSTS_Init */ SW_HOSTS_Init: window = VRInfo( "Object" ) drop window return /*:VRX SW_INTERVALL_Close */ SW_INTERVALL_Close: call SW_INTERVALL_Fini return /*:VRX SW_INTERVALL_Create */ SW_INTERVALL_Create: call SW_INTERVALL_Init call VRSet 'SW_INTERVALL', 'Caption', NLVGetMessage(20) call VRSet 'SW_INTERVALL', 'Font', VRGet("CN_HOSTS","Font") call VRSet 'DT_INTERVALL', 'Caption', NLVGetMessage(23) call VRSet 'CB_DEBUG', 'Caption', NLVGetMessage(24) CALL VRMethod 'TT_Intervall', 'Register', 'SPIN_INTERVALL', NLVGetMessage(55) CALL VRMethod 'TT_Intervall', 'Register', 'DT_INTERVALL', NLVGetMessage(55) CALL VRMethod 'TT_Intervall', 'Register', 'CB_DEBUG', NLVGetMessage(56) ok = VRSet("SPIN_INTERVALL", "Value", INTERVALL / 1000) ok = VRSet("CB_DEBUG","set",options.!debug) return /*:VRX SW_INTERVALL_Fini */ SW_INTERVALL_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_INTERVALL_Init */ SW_INTERVALL_Init: window = VRInfo( "Object" ) drop window return /*:VRX SW_PROGRESS_Close */ SW_PROGRESS_Close: call SW_PROGRESS_Fini return /*:VRX SW_PROGRESS_Create */ SW_PROGRESS_Create: call SW_PROGRESS_Init return /*:VRX SW_PROGRESS_Fini */ SW_PROGRESS_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_PROGRESS_Init */ SW_PROGRESS_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 0 call VRMethod window, "Activate" end drop window return /*:VRX SW_SETTINGS_Close */ SW_SETTINGS_Close: call SW_SETTINGS_Fini return /*:VRX SW_SETTINGS_Create */ SW_SETTINGS_Create: call SW_SETTINGS_Init call VRSet 'PB_SETTINGS_OK', 'Font', VRGet("CN_HOSTS","Font") call VRSet 'PB_SETTINGS_CANCEL', 'Font', VRGet("CN_HOSTS","Font") call VRSet "SW_SETTINGS", "Caption", NLVGetMessage(19) w = VRLoad( "TDL_SETTINGS", VRWindowPath(), "SW_INTERVALL" ) ok = VRMethod( "TDL_SETTINGS", "InsertPage", w,"+ "NLVGetMessage(20)" ") w = VRLoad( "TDL_SETTINGS", VRWindowPath(), "SW_HOSTS" ) ok = VRMethod( "TDL_SETTINGS", "InsertPage", w,"+ "NLVGetMessage(21)" ") w = VRLoad( "TDL_SETTINGS", VRWindowPath(), "SW_ABOUT" ) ok = VRMethod( "TDL_SETTINGS", "InsertPage", w,"+ "NLVGetMessage(22)" ") call VRSet 'PB_SETTINGS_OK', 'Caption', NLVGetMessage(2) call VRSet 'PB_SETTINGS_CANCEL', 'Caption', NLVGetMessage(3) return /*:VRX SW_SETTINGS_Fini */ SW_SETTINGS_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_SETTINGS_Init */ SW_SETTINGS_Init: window = VRInfo( "Object" ) call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window return /*:VRX TDL_SETTINGS_PageSelected */ TDL_SETTINGS_PageSelected: call VRSet "CB_FASTPING", "Visible", 0 call VRSet "CB_SAVEPASSIVE","Visible", 0 call VRSet "CB_SAVEHOSTS", "Visible", 0 call VRSet "CB_NSLOOKUP", "Visible", 0 call VRSet 'SPIN_INTERVALL',"Visible", 0 call VRSet 'DT_INTERVALL', "Visible", 0 call VRSet 'CB_DEBUG', "Visible", 0 select when VRINfo("Page") = 1 then do call VRSet 'SPIN_INTERVALL',"Visible", 1 call VRSet 'DT_INTERVALL', "Visible", 1 call VRSet 'CB_DEBUG', "Visible", 1 end when VRINfo("Page") = 2 then do call VRSet "CB_FASTPING", "Visible", 1 call VRSet "CB_SAVEPASSIVE","Visible", 1 call VRSet "CB_SAVEHOSTS", "Visible", 1 call VRSet "CB_NSLOOKUP", "Visible", 1 end otherwise nop end return /*:VRX TM_PING_Trigger */ TM_PING_Trigger: call _debuglog "TM_PING_Trigger started" call _debuglog "Delay = "VRGet("TM_PING","Delay") call _MACCacheRead ok = VRMethod("CN_HOSTS","GetRecordList","ALL","hosts.") do I = 1 to hosts.0 if Stopped = 1 then leave IP = VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_IP_FH) ok = VRMethod("CN_HOSTS","SetRecordAttr",hosts.I, "Selected", 1) ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_PACKETS_FH, "", CN_HOSTS_LOSS_FH, "",CN_HOSTS_DELAY_FH,"",CN_HOSTS_ANSWER_FH,"") if FastPing = 1 then do if I = 1 then call _FastPing IP IsFast = 0 do J = 1 to fasthosts.0 if word(fasthosts.J,1) = IP then do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'Yes') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$7') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_DELAY_FH, word(fasthosts.J,2)' ms') if NsLookUp = 1 then do resolvedname = _ResolveName(IP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_MAC_FH, _GetMAC(IP)) IsFast = 1 leave end end if IsFast = 0 then do call _pinghost IP ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_MAC_FH, _GetMAC(IP)) ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_PACKETS_FH, transm, CN_HOSTS_LOSS_FH, loss) if strip(loss) = "0%" then do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'Yes') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$5') if NsLookUp = 1 then do resolvedname = _ResolveName(IP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end end if strip(stats) <> "" then do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_DELAY_FH, stats' ms') end else do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'No') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$6') end end end else do call _pinghost IP ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_MAC_FH, _GetMAC(IP)) ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_PACKETS_FH, transm, CN_HOSTS_LOSS_FH, loss) if strip(loss) = "0%" then do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'Yes') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$5') if NsLookUp = 1 then do resolvedname = _ResolveName(IP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",hosts.I, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end end if strip(stats) <> "" then do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_DELAY_FH, stats' ms') end else do ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_ANSWER_FH, 'No') ok = VRMethod("CN_HOSTS","SetFieldData",hosts.I,CN_HOSTS_STATUS_FH, '$6') end end end if FastPing = 1 then do ok = VRMethod("CN_HOSTS","GetRecordList","ALL","hosts.") do J = 1 to fasthosts.0 Found = 0 FastIP = word(fasthosts.J,1) do I = 1 to hosts.0 IP = VRMethod("CN_HOSTS","GetFieldData",hosts.I, CN_HOSTS_IP_FH) if FastIP = IP then do Found = 1 leave end end if Found = 0 then do RH = VRMethod("CN_HOSTS","AddRecord") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_IP_FH, FastIP, CN_HOSTS_NAME_FH, "(unknown)") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_PIP_FH, _pureIP(FastIP), CN_HOSTS_NAME_FH, "(unknown)") ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_MAC_FH, _GetMAC(Fast_IP)) ok = VRMethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_STATUS_FH, '$7') ok = VRMethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_DELAY_FH, word(fasthosts.J,2)' ms') if NsLookUp = 1 then do resolvedname = _ResolveName(IP) if resolvedname <> "error" then ok = VRmethod("CN_HOSTS","SetFieldData",RH, CN_HOSTS_NAME_FH, resolvedname) else ok = VRSet("Main", "HintText", resolvedname" for "IP) end end end end ok = VRMethod("CN_HOSTS","SortRecords") call _MACCacheWrite call _debuglog "TM_PING_Trigger done" return