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

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

GUI-Tools: EVFSGUI 2.5.x: More work done

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