0.9b (c) 1995 Peter Childs
The function returns information about some or all open files on a server.
Syntax
MyRc = NetEnumerate(NETFILE, 'fileInfo', SrvName) MyRc = NetEnumerate(NETFILE, 'fileInfo', SrvName, BasePath) MyRc = NetEnumerate(NETFILE, 'fileInfo', SrvName, BasePath, UserId)
Parameters
The parameters specified are:
'fileInfo' The REXX variable receiving the result. The variable is divided into:
o fileInfo.count
The number of open files. The same value is available in the variable fileInfo.0
o fileInfo.i.id
The file id i, where the variable i has a value from 1 to fileInfo.count
o fileInfo.i.permissions
Indicates the access permissions of the file opening. It is a hexedecimal value combined of the following:
Hex Value What --------- --------------------------------------- 0x1 Permission to read a resource and by default, execute the resource. 0x2 Permission to write to a resource. 0x4 Permission to create a resource. Data can be written when creating the resource.
o fileInfo.i.num_locks
The number of file locks on the file, device, or pipe.
o fileInfo.i.pathname
The path name i, where the variable i has a value from 1 to fileInfo.count
o fileInfo.i.username
The name of the userid that opened the resource.
o fileInfo.frk
On server with many open files, the fileInfo.frk parameter can be used to get a partial enumeration, process the returned information and resume open file enumeration.
To control this operation the value 'INITRESUME' must be specified on the first call and 'RESUME' on the following calls until the returned number of open files is 0 (fileInfo.count)
o fileInfo.frkMoreData
This variable will be set to 234 (ERROR_MORE_DATA) if there is more data available, otherwise the value will be 0
o fileInfo.frkBuffer
The internal binary work buffer size for the fileInfo.frk control parameter. The size should be from 1024 to 65535 bytes. The default value is 4096 bytes
This buffer size is used on every call to hold the binary data, that will be formatted into the returned REXX variables
SrvName The server computer name. If the server computer name is '', it is a call to the local server
BasePath The base path to the open files. For example is 'C:\' a base path
UserId A userid to enumerate open files on
Note
The server computer name can be specified as '' for a local server.
There are 3 different calls to NetEnumerate(NETFILE). They are not identical if one or more specified parameters have the value ''.
An example without the resume key
/* List open files on server */ call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs' call LoadLsRxutFuncs NETFILE = 60 SrvName = '\\DOMAIN_CONTRLR' BasePath = 'C:' UserId = 'ADMIN04' myRc = NetEnumerate(NETFILE, 'fileInfo', SrvName, BasePath, UserId) if myRc <> '0' then do say 'Got error from NetEnumerate() ' myRc call DropLsRxutFuncs exit 9 end if fileInfo.count = 0 then do say 'No files open on the server' call DropLsRxutFuncs exit 0 end say 'Number of open file entries: ' fileInfo.count say do i=1 to fileInfo.count say 'Id ' fileInfo.i.id say 'Permissions ' fileInfo.i.permissions say 'Number locks ' fileInfo.i.num_locks say 'Path Name ' fileInfo.i.pathname say 'Opening Userid' fileInfo.i.username say end call DropLsRxutFuncs call RxFuncDrop 'LoadLsRxutFuncs' exit 0
Example Output
Number of open file entries: 2 Id 142218 Permissions 1 Number locks 0 Path Name C:\OS2\VIEW.EXE Opening Userid ADMIN04 Id 142250 Permissions 1 Number locks 0 Path Name C:\OS2\VIEWDOC.EXE Opening Userid ADMIN04
An example with the resume key
/* Net enumerate open files using resume operation */ call RxFuncAdd 'LoadLsRxutFuncs', 'LSRXUT', 'LoadLsRxutFuncs' call LoadLsRxutFuncs NETFILE = 60 SrvName = '\\KING_BALU' BasePath = '' UserId = 'ADMIN04' fileInfo.frkBuffer = 512 fileInfo.resumekey = 'INITRESUME' myRc = NetEnumerate(NETFILE, 'fileInfo', SrvName) /* Process the file information and test the fileInfo.frkMoreData variable. If 234 then make the following call fileInfo.resumekey = 'RESUME' myRc = NetEnumerate(NETFILE, 'fileInfo', SrvName) */ if myRc <> '0' then do say 'Got error from NetEnumerate() ' myRc ExitRc = 9 end else do if fileInfo.count = 0 then do say 'No files open on the server specified' ExitRc = 0 end else do say 'Number of open file entries: ' fileInfo.count say do i=1 to fileInfo.count say 'Id ' fileInfo.i.id say 'Permissions ' fileInfo.i.permissions say 'Number locks ' fileInfo.i.num_locks say 'Path Name ' fileInfo.i.pathname say 'Opening Userid' fileInfo.i.username say end end end call DropLsRxutFuncs call RxFuncDrop 'LoadLsRxutFuncs' exit rcCode
Inf-HTML End Run - Successful