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

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

GUI-Tools: EVFSGUI 2.5.x: Support WINS, store credentials

File size: 23.1 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 if DoLMHosts = 1 then do
175 call _LMHostsRead
176 call _LMHostsUpdate
177 end
178 ok = VRSet("CN_smbtree", "Painting", 0 )
179 ok = VRSet("CN_smbtree", "Painting", 1 )
180 say time()' _AddSharesDisplay() completed'
181 return /* exit here */
182 end
183 else do
184 say ' 'smbmachine.0' file(s) to process.'
185 if smbmachine.0 = 1 then ok = VRSet("TM_RefreshTreeDisplay", "Delay", VRGet("TM_RefreshTreeDisplay", "Delay") * 2)
186 end
187
188 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
189 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0
190
191 do I = 1 to smbmachine.0
192 call charout , ' Going for "'smbmachine.I'", got '
193 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.')
194 stat = stream(smbmachine.I,'c','open read')
195 say '"'stat'"'
196 if stat = "READY:" & smbmachine.0 = 1 then do /* We just found out we are processing the last machine */
197 ok = VRSet("TM_RefreshTreeDisplay","Delay", 1000)
198 end
199 infoline = ""
200 if stat = "READY:" then do /* we found a readable output file */
201 OneWorkGroupOnly = 0
202
203 Machine = substr(smbmachine.I,pos('.',smbmachine.I)+1)
204
205 smbtree.!machine = _GetMachinehandle(Machine)
206
207 if smbtree.!machine = "" then do /* invalid (old) file */
208 say time()' _AddSharesDisplay() exit with Invalid file found (no corresponding machine)'
209 ok = stream(smbmachine.I,'c','close')
210 ok = SysFileDelete(smbmachine.I)
211 iterate
212 end
213 line = linein(smbmachine.I) /* PID line */
214 line = linein(smbmachine.I)
215 if pos('creating lame', line) > 0 then do
216 line = linein(smbmachine.I)
217 line = linein(smbmachine.I)
218 end
219 if pos('Server=[', line) > 0 then do
220 infoline = linein(smbmachine.I)
221 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest
222 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS, VersionFH, Server)
223 line = linein(smbmachine.I)
224 end
225 say ' Answer "'line'"'
226 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line))
227
228 if pos("FAIL", translate(line)) > 0 then do /* we see an error message - the term "FAIL" seems to be common to all */
229 say time()' _AddSharesDisplay() exit with "'line'"'
230 ok = stream(smbmachine.I,'c','close')
231 ok = SysFileDelete(smbmachine.I)
232 iterate
233 end
234
235 retries = 0
236 do while(left(line,1) <> '09'x)
237 line = linein(smbmachine.I)
238 retries = retries + 1
239 say ' Skip 'retries' "'line'"'
240 if retries >=10 then do /* No valid output - error */
241 say time()' _AddSharesDisplay() exit with invalid output error'
242 ok = stream(smbmachine.I,'c','close')
243 ok = SysFileDelete(smbmachine.I)
244 leave
245 end
246 end
247 if retries >=10 then iterate
248
249 /* Skip header */
250 line = linein(smbmachine.I)
251 line = linein(smbmachine.I)
252
253 if translate(left(strip(line),5)) = "ERROR" then ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line))
254
255 do while(left(line,1) = '09'x) /* Share loop */
256 parse var line '09'x share type comment
257 type = translate(strip(type))
258 comment = strip(comment)
259
260 select
261 when type = "DISK" then res = '#64:PMWP.DLL'
262 when type = "PRINTER" then res = '#65:PMWP.DLL'
263 when type = "IPC" then res = '#59:PMWP.DLL'
264 when type = "DEVICE" then res = '#84:PMWP.DLL' /* There might be better ones around */
265 otherwise res = ''
266 end
267
268 /* Now the machine receives the wakeup icon */
269 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Icon', "#35:PMWP.DLL")
270 parent = smbtree.!machine
271 smbtree.!share = VRMethod( "CN_smbtree", "AddRecord",parent,, share||'0D0A'x||comment, res)
272 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "ReadOnly", 1, 'UserData', type"|")
273 if pos("$", share) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "Visible", ShowHidden)
274
275 /* get next share */
276 line = linein(smbmachine.I)
277 end /* Share loop */
278
279 do until left(line,10) = '09'x||'Workgroup'
280 line = linein(smbmachine.I)
281 end
282 line = linein(smbmachine.I)
283 /* Reading FIRST workgroup and master - eventually both empty */
284 line = linein(smbmachine.I)
285
286 /* Multiple workgroups? */
287 if lines(smbmachine.I) = 0 then OneWorkGroupOnly = 1
288 else OneWorkGroupOnly = 0
289 say " OneWorkGroupOnly = "OneWorkGroupOnly
290
291 parse var line '09'x workgroup master
292 master = strip(master)
293
294 /* we use this to set the workgroup for manually added servers - if there is ONLY ONE workgroup */
295 if workgroup <> "" & OneWorkGroupOnly = 1 then do
296 wgh = _GetMachinehandle(workgroup)
297 if wgh = "" then do /* The machine appears to be in a new workgroup - add it as well */
298 /* NOTE: This should be obsolete now because the list of available */
299 /* workgroups should always have been updated before we get here */
300 wgh = _AddWorkGroup(workgroup)
301 end
302 /* we only do this for machines with empty parent (=workgroup) handle */
303 /* IF there is only one workgroup */
304 if wgh <> "" & VRMethod('CN_smbtree', 'GetRecordAttr', smbtree.!machine, 'Parent') = "" then do
305 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Parent', wgh)
306 end
307 end
308 else do
309 if workgroup <> "" then do
310 /* There are multiple workgroups, we need additional */
311 /* measures to find out which is our workgroup */
312 if infoline <> "" then do
313 say ' 'samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL'
314 address cmd samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL'
315 infoline = linein(samba.!msg)
316
317 if word(infoline,1) = "creating" then do /* upcase tables are missing */
318 say "Missing upcase tables detected!"
319 infoline = linein(samba.!msg)
320 infoline = linein(samba.!msg)
321 end
322 IF options.!debug == 1 THEN say ' Response = "'Infoline'"'
323 ok = stream(samba.!msg,'c','close')
324 ok = SysFileDelete(samba.!msg)
325 end
326
327 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest
328
329 wgh = _GetMachinehandle(workgroup)
330 if wgh <> "" & VRMethod('CN_smbtree', 'GetRecordAttr', smbtree.!machine, 'Parent') = "" then do
331 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Parent', wgh)
332 end
333 end
334 else do
335 /* The machine does not allow browsing and does not report a workgroup here */
336 say ' "'Machine'" does not allow browsing.'
337 end
338 end
339
340 ok = VRSet("Main", 'Pointer', 'Wait' )
341
342 /* Get NMBLookup Status for machine */
343 NMBStatus = _GetMachineNMBSTatus(machine)
344 parse var NMBStatus IPStr'|'MAC '|' Roles; drop NMBStatus
345 if pos("PDC",Roles) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#63:PMWP.DLL")
346 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr,MBFH, Roles, MacFH,MAC)
347
348 ok = VRSet("Main", 'Pointer', '<default>' )
349
350 say time()' _AddSharesDisplay() success and cleanup'
351 ok = stream(smbmachine.I,'c','close')
352 ok = SysFileDelete(smbmachine.I)
353 if ok <> 0 then say ' Failure 'ok' deleting "'smbmachine.I'"!'
354 end
355 end
356
357 if UserCred = '-N' then UserCred = ''
358
359 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", "Ready.")
360 say time()' _AddSharesDisplay() loop end'
361return
362
363/*:VRX _GetMachinehandle
364*/
365
366_GetMachinehandle: procedure /* get recordhandle by machine name (also works for workgroups) */
367 Machine = translate(arg(1))
368 say ' _GetMachineHandle("'Machine'") started.'
369 ok = VRMethod("CN_smbtree", "GetRecordList", "All", rh.)
370 match = 0
371
372 do I = 1 to rh.0
373 ResName = translate(VRMethod("CN_smbtree","GetRecordAttr",rh.I,"Caption"))
374
375 parse var ResName ResName '0D0A'x .
376 ResName = strip(ResName)
377
378 if Machine = ResName then do /* we got a matching name */
379 match = 1
380 leave
381 end
382 end
383 if match = 0 then rh.I = "" /* return an empty handle, if there was no match */
384 say ' _GetMachineHandle("'Machine'") done, handle = "'rh.I'"'
385return rh.I
386
387/*:VRX _RefreshWorkgroups
388*/
389_RefreshWorkgroups:
390 say time()' _RefreshWorkgroups() started'
391 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N'
392 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = ''
393
394 say ' 'samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg
395 address cmd samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg
396
397 if BroadCast = '-b' then BroadCast = 1; else BroadCast = 0
398 if UserCred = '-N' then UserCred = ''
399
400 ok = File2Stem(samba.!msg,"workgroups.")
401 do I = 1 to workgroups.0
402 workgroup = translate(workgroups.I)
403 if pos("RECEIVING",workgroup) > 0 | pos("TDB(",workgroup) > 0 then iterate /* We ignore errors here */
404 wgh = _GetMachinehandle(workgroup)
405 if wgh = "" then wgh = _AddWorkGroup(workgroup) /* A new workgroup was found -- add it */
406 end
407 say time()' _RefreshWorkgroups() done'
408return
409
410/*:VRX _AddWorkgroup
411*/
412_AddWorkGroup: procedure expose WorkGroupFH
413 workgroup = arg(1)
414 say ' _AddWorkGroup("'workgroup'") started.'
415 wgh= VRMethod( "CN_smbtree", "AddRecord",,, workgroup,"#62:PMWP.DLL")
416 ok = VRMethod( "CN_smbtree", "SetFieldData", wgh, WorkGroupFH, workgroup)
417 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "Collapsed", 0)
418 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "ReadOnly", 1)
419 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', wgh, "UserData", "WORKGROUP|")
420 say ' _AddWorkGroup("'workgroup'") done.'
421return wgh
422
423/*:VRX _AddSleepingMachine
424*/
425_AddSleepingMachine: procedure expose WorkGroupFH NBFH CommentFH
426 machine = arg(1)
427 comment = arg(2)
428 parent = arg(3)
429 mh = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment)
430 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, NBFH, machine, CommentFH, comment)
431 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Icon","#61:PMWP.DLL")
432 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "ReadOnly", 1)
433 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Collapsed", 1)
434 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', mh, "UserData", "SERVER|")
435 if parent <> "" then do
436 WGName = translate(VRMethod("CN_smbtree","GetRecordAttr",parent,"Caption"))
437 parse var WGName WGName '0D0A'x .
438 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, WorkgroupFH, strip(WGName))
439 end
440return mh
441
442/*:VRX _GetMachineIP
443*/
444_GetMachineIP: procedure expose debuglevel samba.
445 /* Get all IP addresses of the machine */
446 machine = arg(1)
447 say ' 'samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg
448 address cmd samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg
449 ok = file2stem(samba.!msg,"nmblookup.")
450 ipstr = ""; ip = ""
451 do i = 1 to nmblookup.0
452 if pos(strip(machine)'<',nmblookup.i) = 0 then iterate
453 parse var nmblookup.i ip .
454 if pos(strip(ip), ipstr) = 0 then ipstr = ipstr||ip','
455 end
456 ipstr = strip(ipstr,,',')
457return IpStr
458
459/*:VRX _GetMachineRole
460*/
461_GetMachineMACRoles: procedure expose debuglevel samba.
462 machine = arg(1) /* May be name or IP */
463 say ' 'samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg
464 address cmd samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg
465 ok = file2stem(samba.!msg,"nmblookup.")
466 Roles = ""
467 MAC = 'xx-xx-xx-xx-xx-xx'
468 do I = 1 to nmblookup.0
469 select
470 when pos('<1c>', nmblookup.I) > 0 then Roles = Roles||"PDC," /* # */
471 when pos('<1b>', nmblookup.I) > 0 then Roles = Roles||"LMB," /* + */
472 when pos('<1d>', nmblookup.I) > 0 then Roles = Roles||"DMB," /* * */
473 when pos('MAC', nmblookup.I) > 0 then do
474 parse var nmblookup.I . '=' MAC
475 MAC = strip(MAC)
476 end
477 otherwise nop
478 end
479 end
480 Roles = strip(Roles,,',')
481 if Roles = "" then Roles = "Workstation"
482return MAC'|'Roles
483
484/*:VRX _GetMachineNMBStatus
485*/
486_GetMachineNMBStatus: procedure expose debuglevel samba.
487 machine = arg(1) /* name only allowed */
488 say ' 'samba.!nmblookupexe' -S 'machine' 'debuglevel' >'samba.!msg
489 address cmd samba.!nmblookupexe' -S 'machine' 'debuglevel' >'samba.!msg
490 ok = file2stem(samba.!msg,"nmblookup.")
491 IPStr = ""
492 Roles = ""
493 MAC = 'xx-xx-xx-xx-xx-xx'
494 do I = 1 to nmblookup.0
495 select
496 when pos(machine'<',nmblookup.I) > 0 then do
497 parse var nmblookup.i ip .
498 ip = strip(ip)
499 if pos(ip, ipstr) = 0 then ipstr = ipstr||ip','
500 end
501 when pos('<1c>', nmblookup.I) > 0 then Roles = Roles||"PDC," /* # */
502 when pos('<1b>', nmblookup.I) > 0 then Roles = Roles||"LMB," /* + */
503 when pos('<1d>', nmblookup.I) > 0 then Roles = Roles||"DMB," /* * */
504 when pos('MAC', nmblookup.I) > 0 then do
505 parse var nmblookup.I . '=' MAC
506 MAC = strip(MAC)
507 end
508 otherwise nop
509 end
510 end
511 Roles = strip(Roles,,',')
512 if Roles = "" then Roles = "Workstation"
513 ipstr = strip(ipstr,,',')
514return IPStr'|'MAC'|'Roles
515
516
517
518/*:VRX file2stem
519*/
520file2stem:
521 msgfile = arg(1)
522 msgstem = arg(2)
523 delmsgfile = translate(arg(3))
524 if right(msgstem,1) <> '.' then msgstem = msgstem'.'
525 say ' file2stem("'msgfile'","'msgstem'")'
526 dyn = 'drop 'msgstem
527 interpret dyn
528 stemcount = 0
529 do while lines(msgfile) > 0
530 stemcount = stemcount + 1
531 inline = linein(msgfile)
532 if pos('creating lame',inline) > 0 then do
533 stemcount = stemcount - 1
534 iterate
535 end
536 dyn = msgstem||stemcount' = inline'
537 interpret dyn
538 end
539 dyn = msgstem||"0 = "stemcount
540 interpret dyn
541 ok = stream(msgfile,'c','close')
542 if delMsgFile <> "NODEL" then ok = SysFileDelete(msgfile)
543 drop msgfile msgstem
544return stemcount
Note: See TracBrowser for help on using the repository browser.