source: trunk/guitools/shared/smbtree.vrs@ 689

Last change on this file since 689 was 688, checked in by Herwig Bauernfeind, 14 years ago

GUI-Tools: Updates in EVFSGUI, SMBMON and SSCC

File size: 25.1 KB
Line 
1/* Routines to handle smbtree output */
2
3/*:VRX */
4_RefreshTree:
5 say time()' _RefreshTree() started'
6 FirstRun = 0
7 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", "Refreshing network")
8 ok = SysFileDelete(samba.!msg)
9
10 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
11 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0
12 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = ''
13
14 say " UserCred="UserCred
15 samba.!serverlist = TempDir'smbtree.srvlst'
16
17 /* smbtree -S = List workgroups (domains) and servers of tree */
18 say ' detach 'samba.!smbtreeexe' 'BroadCast' -S 'UserCred' 'debuglevel' >'samba.!serverlist
19 address cmd 'detach 'samba.!smbtreeexe' 'BroadCast' -S 'UserCred' 'debuglevel' >'samba.!serverlist
20
21 if BroadCast = '-b' then BroadCast = 1; else BroadCast = 0
22 if UserCred = '-N' then UserCred = ''
23
24 ok = VRMethod("CN_smbtree", "RemoveRecord", "ALL")
25
26 RefreshMode = "TREE"
27 ok = VRSet("CN_smbtree","Enabled", 0)
28 ok = VRset("TM_RefreshTreeDisplay","Enabled",1)
29
30 say time()' _RefreshTree() done'
31return
32
33/*:VRX */
34_RefreshTreeDisplay:
35 say time()' _RefreshTreeDisplay() started'
36
37 stat = stream(samba.!serverlist,'c','open read')
38 if stat <> "READY:" then do
39 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
40 return
41 end
42
43 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
44 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0
45 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = ''
46
47 ok = VRset("TM_RefreshTreeDisplay","Enabled",0)
48 ok = VRSet("CN_smbtree", 'Enabled', 0 )
49
50 ok = VRSet( "CN_smbtree", "Painting", 0 )
51 ok = VRMethod("CN_smbtree", "RemoveRecord", "ALL")
52
53 drop smbtree.
54
55 ok = file2stem(samba.!serverlist,"smbtreeline.")
56
57 do sl = 1 to smbtreeline.0
58 Header = c2x(left(smbtreeline.sl,3))
59 select
60 when Header = "09095C" then nop /* share - obsolete, we only list domains and servers here */
61 when Header = "095C5C" then do /* machine */
62 smbtreeline.sl = strip(smbtreeline.sl,,'09'x)
63 parse var smbtreeline.sl '\\'machine '0909'x comment
64 machine = strip(machine)
65 comment = strip(comment)
66 if VRGet("CN_smbtree","View") = "IconTree" then parent = smbtree.!workgroup; else parent = ""
67 /* We make any machine as sleeping initially */
68 smbtree.!machine = _AddSleepingMachine(machine,comment,parent)
69
70 ok = VRSet( "CN_smbtree", "Painting", 1 )
71 ok = VRSet( "CN_smbtree", "Painting", 0 )
72
73 if VRGet("CN_smbtree","View") <> "Detail" then do
74 /* Tree view */
75 call _RefreshShares
76 end
77 else do /* Fill records for details view */
78 ok = VRSet("Main", 'Pointer', 'Wait' )
79 /* Get NMBLookup Status for machine */
80 NMBStatus = _GetMachineNMBSTatus(machine)
81 parse var NMBStatus IPStr'|'MAC '|' Roles; drop NMBStatus
82 if pos("PDC",Roles) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#63:PMWP.DLL")
83 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr,MBFH, Roles, MacFH,MAC)
84
85 /* FIXME: Possibly obsolete */
86 parse var IPStr MachineIP ',' .
87 if strip(MachineIP) = "" then MachineIP = machine
88
89 ok = VRSet("Main", 'Pointer', '<default>' )
90
91 /* Find out OS, version */
92 say ' 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'samba.!msg' 1>NUL'
93 address cmd samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'samba.!msg' 1>NUL'
94 smbline = linein(samba.!msg)
95 ok = stream(samba.!msg,'c','close')
96 parse var smbline "Domain=["WorkGroup"] OS=["OS"] Server=["Version"]"Rest
97 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS, VersionFH, Version, WorkgroupFH, WorkGroup)
98 end
99 end
100 when smbtreeline.sl = "" then nop /* skip empty lines */
101 otherwise do /* possibly a new workgroup */
102 say ' Possible workgroup: "'smbtreeline.sl'"'
103 /* check for eventual error messages */
104 if pos("RECEIVING",translate(smbtreeline.sl)) > 0 | pos("TDB(",translate(smbtreeline.sl)) > 0 then do
105 Msg.Type = "W"
106 Msg.Text = smbtreeline.sl
107 call _ShowMsg
108 end
109 else do /* it is really a new workgroup */
110 if VRGet("CN_smbtree","View") = "IconTree" then do
111 smbtree.!workgroup = _AddWorkGroup(smbtreeline.sl)
112 end
113 CurWG = smbtreeline.sl
114 end
115 end
116 end
117 end
118
119 ok = VRSet( "CN_smbtree", "Painting", 1 )
120
121/* ok = VRSet("Main", 'Pointer', '<default>' ) */
122 ok = VRSet("CN_smbtree","Enabled", 1)
123 ok = VRSet("TM_Throbber","Enabled", 0)
124 ok = VRSet("Pict_Throbber","Visible", 0)
125 say time()' _RefreshTreeDisplay() done'
126return
127
128/*:VRX _RefreshShares */
129_RefreshShares:
130 say time()' _RefreshShares() started'
131
132 smbmachine = TempDir||"smbmachine."||machine
133 MaxSmbClient = 32 /* Do not run more than MaxSmbClient instances of smbclient.exe at the same time */
134
135 Defer = 1
136 do while Defer = 1
137 SmbCltCount = 0
138 ok = PRProcessList(proc)
139
140 do I = 1 to proc.0
141 CurProc = VRParseFileName(proc.i.name,'NE')
142 if CurProc = "SMBCLIENT.EXE" then SmbCltCount = SmbCltCount + 1
143 end
144 say ' 'SmbCltCount' instance(s) of 'samba.!smbclientexe' is/are running.'
145 if SmbCltCount >= MaxSmbClient then do
146 say " Waiting until at least "SmbCltCount-MaxSmbClient+1" instance(s) of smbclient.exe terminate(s)."
147 ok = SysSleep(1)
148 end
149 else Defer = 0
150 end
151
152 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
153
154 say ' detach 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'smbmachine' 1>&2'
155 address cmd 'detach 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'smbmachine' 1>&2'
156
157 if UserCred = '-N' then UserCred = ''
158
159 RefreshMode = "SHARE"
160
161 ok = VRSet("CN_smbtree","Enabled", 0)
162 ok = VRset("TM_RefreshTreeDisplay","Enabled",1)
163 say time()' _RefreshShares() done'
164return
165
166/*:VRX _AddSharesDisplay
167*/
168_AddSharesDisplay: /* New get shares code - uses smbclient output and is much faster */
169 say time()' _AddSharesDisplay() started'
170
171 ok = SysFileTree(Tempdir||'smbmachine.*',smbmachine.,'FO')
172 if smbmachine.0 = 0 then do /* we are done, no more files around, cleanup, disable Timer and exit */
173 RefreshMode = ""
174 ok = VRset("TM_RefreshTreeDisplay","Enabled", 0)
175 ok = VRSet("TM_RefreshTreeDisplay","Delay", 1000)
176 ok = VRSet("CN_smbtree","Enabled", 1)
177 if DoLMHosts = 1 then do
178 call _LMHostsRead
179 call _LMHostsUpdate
180 end
181 ok = VRSet("CN_smbtree", "Painting", 0 )
182 ok = VRSet("CN_smbtree", "Painting", 1 )
183 say time()' _AddSharesDisplay() completed'
184 return /* exit here */
185 end
186 else do
187 say ' 'smbmachine.0' file(s) to process.'
188 if smbmachine.0 = 1 then ok = VRSet("TM_RefreshTreeDisplay", "Delay", VRGet("TM_RefreshTreeDisplay", "Delay") * 2)
189 end
190
191 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
192 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0
193
194 do I = 1 to smbmachine.0
195 call charout , ' Going for "'smbmachine.I'", got '
196 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
197 stat = stream(smbmachine.I,'c','open read')
198 say '"'stat'"'
199 if stat = "READY:" & smbmachine.0 = 1 then do /* We just found out we are processing the last machine */
200 ok = VRSet("TM_RefreshTreeDisplay","Delay", 1000)
201 end
202 infoline = ""
203 if stat = "READY:" then do /* we found a readable output file */
204 OneWorkGroupOnly = 0
205
206 Machine = substr(smbmachine.I,pos('.',smbmachine.I)+1)
207
208 smbtree.!machine = _GetMachinehandle(Machine)
209
210 if smbtree.!machine = "" then do /* invalid (old) file */
211 say time()' _AddSharesDisplay() exit with Invalid file found (no corresponding machine)'
212 ok = stream(smbmachine.I,'c','close')
213 ok = SysFileDelete(smbmachine.I)
214 iterate
215 end
216 line = linein(smbmachine.I) /* PID line */
217 line = linein(smbmachine.I)
218 if pos('creating lame', line) > 0 then do
219 line = linein(smbmachine.I)
220 line = linein(smbmachine.I)
221 end
222 if pos('Server=[', line) > 0 then do
223 infoline = linein(smbmachine.I)
224 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest
225 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS, VersionFH, Server)
226 line = linein(smbmachine.I)
227 end
228 say ' Answer "'line'"'
229 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line))
230
231 if pos("FAIL", translate(line)) > 0 then do /* we see an error message - the term "FAIL" seems to be common to all */
232 say time()' _AddSharesDisplay() exit with "'line'"'
233 ok = stream(smbmachine.I,'c','close')
234 ok = SysFileDelete(smbmachine.I)
235 iterate
236 end
237
238 retries = 0
239 do while(left(line,1) <> '09'x)
240 line = linein(smbmachine.I)
241 retries = retries + 1
242 say ' Skip 'retries' "'line'"'
243 if retries >=10 then do /* No valid output - error */
244 say time()' _AddSharesDisplay() exit with invalid output error'
245 ok = stream(smbmachine.I,'c','close')
246 ok = SysFileDelete(smbmachine.I)
247 leave
248 end
249 end
250 if retries >=10 then iterate
251
252 /* Skip header */
253 line = linein(smbmachine.I)
254 line = linein(smbmachine.I)
255
256 if translate(left(strip(line),5)) = "ERROR" then ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line))
257
258 do while(left(line,1) = '09'x) /* Share loop */
259 parse var line '09'x share type comment
260 type = translate(strip(type))
261 comment = strip(comment)
262
263 select
264 when type = "DISK" then res = '#64:PMWP.DLL'
265 when type = "PRINTER" then res = '#65:PMWP.DLL'
266 when type = "IPC" then res = '#59:PMWP.DLL'
267 when type = "DEVICE" then res = '#84:PMWP.DLL' /* There might be better ones around */
268 otherwise res = ''
269 end
270
271 /* Now the machine receives the wakeup icon */
272 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Icon', "#35:PMWP.DLL")
273 parent = smbtree.!machine
274 smbtree.!share = VRMethod( "CN_smbtree", "AddRecord",parent,, share||'0D0A'x||comment, res)
275 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "ReadOnly", 1, 'UserData', type"|")
276 if pos("$", share) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "Visible", ShowHidden)
277
278 /* get next share */
279 line = linein(smbmachine.I)
280 end /* Share loop */
281
282 do until left(line,10) = '09'x||'Workgroup'
283 line = linein(smbmachine.I)
284 end
285 line = linein(smbmachine.I)
286 /* Reading FIRST workgroup and master - eventually both empty */
287 line = linein(smbmachine.I)
288
289 /* Multiple workgroups? */
290 if lines(smbmachine.I) = 0 then OneWorkGroupOnly = 1
291 else OneWorkGroupOnly = 0
292 say " OneWorkGroupOnly = "OneWorkGroupOnly
293
294 parse var line '09'x workgroup master
295 master = strip(master)
296
297 /* we use this to set the workgroup for manually added servers - if there is ONLY ONE workgroup */
298 if workgroup <> "" & OneWorkGroupOnly = 1 then do
299 wgh = _GetMachinehandle(workgroup)
300 if wgh = "" then do /* The machine appears to be in a new workgroup - add it as well */
301 /* NOTE: This should be obsolete now because the list of available */
302 /* workgroups should always have been updated before we get here */
303 wgh = _AddWorkGroup(workgroup)
304 end
305 /* we only do this for machines with empty parent (=workgroup) handle */
306 /* IF there is only one workgroup */
307 if wgh <> "" & VRMethod('CN_smbtree', 'GetRecordAttr', smbtree.!machine, 'Parent') = "" then do
308 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Parent', wgh)
309 end
310 end
311 else do
312 if workgroup <> "" then do
313 /* There are multiple workgroups, we need additional */
314 /* measures to find out which is our workgroup */
315 if infoline <> "" then do
316 say ' 'samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL'
317 address cmd samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL'
318 infoline = linein(samba.!msg)
319
320 if word(infoline,1) = "creating" then do /* upcase tables are missing */
321 say "Missing upcase tables detected!"
322 infoline = linein(samba.!msg)
323 infoline = linein(samba.!msg)
324 end
325 IF options.!debug == 1 THEN say ' Response = "'Infoline'"'
326 ok = stream(samba.!msg,'c','close')
327 ok = SysFileDelete(samba.!msg)
328 end
329
330 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest
331
332 wgh = _GetMachinehandle(workgroup)
333 if wgh <> "" & VRMethod('CN_smbtree', 'GetRecordAttr', smbtree.!machine, 'Parent') = "" then do
334 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Parent', wgh)
335 end
336 end
337 else do
338 /* The machine does not allow browsing and does not report a workgroup here */
339 say ' "'Machine'" does not allow browsing.'
340 end
341 end
342
343 ok = VRSet("Main", 'Pointer', 'Wait' )
344
345 /* Get NMBLookup Status for machine */
346 NMBStatus = _GetMachineNMBSTatus(machine)
347 parse var NMBStatus IPStr'|'MAC '|' Roles; drop NMBStatus
348 if pos("PDC",Roles) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#63:PMWP.DLL")
349 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr,MBFH, Roles, MacFH,MAC)
350
351 ok = VRSet("Main", 'Pointer', '<default>' )
352
353 say time()' _AddSharesDisplay() success and cleanup'
354 ok = stream(smbmachine.I,'c','close')
355 ok = SysFileDelete(smbmachine.I)
356 if ok <> 0 then say ' Failure 'ok' deleting "'smbmachine.I'"!'
357 end
358 end
359
360 if UserCred = '-N' then UserCred = ''
361
362 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", "Ready.")
363 say time()' _AddSharesDisplay() loop end'
364return
365
366/*:VRX _GetMachinehandle
367*/
368
369_GetMachinehandle: procedure /* get recordhandle by machine name (also works for workgroups) */
370 Machine = translate(arg(1))
371 say ' _GetMachineHandle("'Machine'") started.'
372 ok = VRMethod("CN_smbtree", "GetRecordList", "All", rh.)
373 match = 0
374
375 do I = 1 to rh.0
376 ResName = translate(VRMethod("CN_smbtree","GetRecordAttr",rh.I,"Caption"))
377
378 parse var ResName ResName '0D0A'x .
379 ResName = strip(ResName)
380
381 if Machine = ResName then do /* we got a matching name */
382 match = 1
383 leave
384 end
385 end
386 if match = 0 then rh.I = "" /* return an empty handle, if there was no match */
387 say ' _GetMachineHandle("'Machine'") done, handle = "'rh.I'"'
388return rh.I
389
390/*:VRX _RefreshWorkgroups
391*/
392_RefreshWorkgroups:
393 say time()' _RefreshWorkgroups() started'
394 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
395 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = ''
396
397 call VRSet VRWindow(), 'Pointer', 'Wait'
398 say ' detach 'samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg
399 address cmd 'detach 'samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg
400
401 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption","Enumerating workgroups")
402 do while stream(samba.!msg,'c','open read') <> "READY:"
403 ok = SysSleep(1)
404 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
405 end
406 call VRSet VRWindow(), 'Pointer', '<default>'
407
408 if BroadCast = '-b' then BroadCast = 1; else BroadCast = 0
409 if UserCred = '-N' then UserCred = ''
410
411 ok = File2Stem(samba.!msg,"workgroups.")
412 do I = 1 to workgroups.0
413 workgroup = translate(workgroups.I)
414 if pos("RECEIVING",workgroup) > 0 | pos("TDB(",workgroup) > 0 then iterate /* We ignore errors here */
415 wgh = _GetMachinehandle(workgroup)
416 if wgh = "" then wgh = _AddWorkGroup(workgroup) /* A new workgroup was found -- add it */
417 end
418 say time()' _RefreshWorkgroups() done'
419return
420
421/*:VRX _AddWorkgroup
422*/
423_AddWorkGroup: procedure expose WorkGroupFH
424 workgroup = arg(1)
425 say ' _AddWorkGroup("'workgroup'") started.'
426 wgh= VRMethod( "CN_smbtree", "AddRecord",,, workgroup,"#62:PMWP.DLL")
427 ok = VRMethod( "CN_smbtree", "SetFieldData", wgh, WorkGroupFH, workgroup)
428 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "Collapsed", 0)
429 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "ReadOnly", 1)
430 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', wgh, "UserData", "WORKGROUP|")
431 say ' _AddWorkGroup("'workgroup'") done.'
432return wgh
433
434/*:VRX _AddSleepingMachine
435*/
436_AddSleepingMachine: procedure expose WorkGroupFH NBFH CommentFH
437 machine = arg(1)
438 comment = arg(2)
439 parent = arg(3)
440 mh = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment)
441 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, NBFH, machine, CommentFH, comment)
442 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Icon","#61:PMWP.DLL")
443 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "ReadOnly", 1)
444 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Collapsed", 1)
445 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', mh, "UserData", "SERVER|")
446 if parent <> "" then do
447 WGName = translate(VRMethod("CN_smbtree","GetRecordAttr",parent,"Caption"))
448 parse var WGName WGName '0D0A'x .
449 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, WorkgroupFH, strip(WGName))
450 end
451return mh
452
453/*:VRX _GetMachineIP
454*/
455_GetMachineIP: procedure expose debuglevel samba.
456 /* Get all IP addresses of the machine */
457 machine = arg(1)
458 call VRSet VRWindow(), 'Pointer', 'Wait'
459 say ' detach 'samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg
460 address cmd 'detach 'samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg
461
462 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption","Obtaining IP from "machine)
463 do while stream(samba.!msg,'c','open read') <> "READY:"
464 ok = SysSleep(0.33)
465 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
466 end
467 call VRSet VRWindow(), 'Pointer', '<default>'
468
469 ok = file2stem(samba.!msg,"nmblookup.")
470 ipstr = ""; ip = ""
471 do i = 1 to nmblookup.0
472 if pos(strip(machine)'<',nmblookup.i) = 0 then iterate
473 parse var nmblookup.i ip .
474 if pos(strip(ip), ipstr) = 0 then ipstr = ipstr||ip','
475 end
476 ipstr = strip(ipstr,,',')
477return IpStr
478
479/*:VRX _GetMachineRole
480*/
481_GetMachineMACRoles: procedure expose debuglevel samba.
482 machine = arg(1) /* May be name or IP */
483 call VRSet VRWindow(), 'Pointer', 'Wait'
484 say ' detach 'samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg
485 address cmd 'detach 'samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg
486
487 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption","Obtaining capabilities from "machine)
488 do while stream(samba.!msg,'c','open read') <> "READY:"
489 ok = SysSleep(0.33)
490 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
491 end
492 call VRSet VRWindow(), 'Pointer', '<default>'
493 ok = file2stem(samba.!msg,"nmblookup.")
494 Roles = ""
495 MAC = 'xx-xx-xx-xx-xx-xx'
496 do I = 1 to nmblookup.0
497 select
498 when pos('<1c>', nmblookup.I) > 0 then Roles = Roles||"PDC," /* # */
499 when pos('<1b>', nmblookup.I) > 0 then Roles = Roles||"LMB," /* + */
500 when pos('<1d>', nmblookup.I) > 0 then Roles = Roles||"DMB," /* * */
501 when pos('MAC', nmblookup.I) > 0 then do
502 parse var nmblookup.I . '=' MAC
503 MAC = strip(MAC)
504 end
505 otherwise nop
506 end
507 end
508 Roles = strip(Roles,,',')
509 if Roles = "" then Roles = "Workstation"
510return MAC'|'Roles
511
512/*:VRX _GetMachineNMBStatus
513*/
514_GetMachineNMBStatus: procedure expose debuglevel samba.
515 machine = arg(1) /* name only allowed */
516 call VRSet VRWindow(), 'Pointer', 'Wait'
517 say ' detach 'samba.!nmblookupexe' -S 'machine' 'debuglevel' >'samba.!msg
518 address cmd 'detach 'samba.!nmblookupexe' -S 'machine' 'debuglevel' >'samba.!msg
519
520 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption","Querying "machine" for roles")
521 do while stream(samba.!msg,'c','open read') <> "READY:"
522 ok = SysSleep(0.33)
523 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
524 end
525 call VRSet VRWindow(), 'Pointer', '<default>'
526
527 ok = file2stem(samba.!msg,"nmblookup.")
528 IPStr = ""
529 Roles = ""
530 MAC = 'xx-xx-xx-xx-xx-xx'
531 do I = 1 to nmblookup.0
532 select
533 when pos(machine'<',nmblookup.I) > 0 then do
534 parse var nmblookup.i ip .
535 ip = strip(ip)
536 if pos(ip, ipstr) = 0 then ipstr = ipstr||ip','
537 end
538 when pos('<1c>', nmblookup.I) > 0 then Roles = Roles||"PDC," /* # */
539 when pos('<1b>', nmblookup.I) > 0 then Roles = Roles||"LMB," /* + */
540 when pos('<1d>', nmblookup.I) > 0 then Roles = Roles||"DMB," /* * */
541 when pos('MAC', nmblookup.I) > 0 then do
542 parse var nmblookup.I . '=' MAC
543 MAC = strip(MAC)
544 end
545 otherwise nop
546 end
547 end
548 Roles = strip(Roles,,',')
549 if Roles = "" then Roles = "Workstation"
550 ipstr = strip(ipstr,,',')
551return IPStr'|'MAC'|'Roles
552
553
554
555/*:VRX file2stem
556*/
557file2stem:
558 msgfile = arg(1)
559 msgstem = arg(2)
560 delmsgfile = translate(arg(3))
561 if right(msgstem,1) <> '.' then msgstem = msgstem'.'
562 say ' file2stem("'msgfile'","'msgstem'")'
563 dyn = 'drop 'msgstem
564 interpret dyn
565 stemcount = 0
566 do while lines(msgfile) > 0
567 stemcount = stemcount + 1
568 inline = linein(msgfile)
569 if pos('creating lame',inline) > 0 then do
570 stemcount = stemcount - 1
571 iterate
572 end
573 dyn = msgstem||stemcount' = inline'
574 interpret dyn
575 end
576 dyn = msgstem||"0 = "stemcount
577 interpret dyn
578 ok = stream(msgfile,'c','close')
579 if delMsgFile <> "NODEL" then ok = SysFileDelete(msgfile)
580 drop msgfile msgstem
581return stemcount
Note: See TracBrowser for help on using the repository browser.