ctGetOpenFiles
Declaration
NINT ctGetOpenFiles(COUNT ConnectionNumber, pctFILINF pFileInfo, pLONG pNbrFiles);
Description
Returns the names of all open FairCom DB files or all files open by a specified connection.
typedef struct ctfilinfo {
FILNO filno; /* system file number */
FILNO status; /* user count or user file number */
TEXT filtyp; /* file type */
TEXT suptyp; /* superfile type */
TEXT filnam[255]; /* file name */
} ctFILINF, ctMEM * pctFILINF;
To retrieve the names of all files open by the FairCom Server, set ConnectionNumber to -1. To retrieve the names of all files open by a specified connection, set ConnectionNumber to the task ID for the connection as shown in the ctadmn utility's list of active connections, which is returned by the USERLIST() and USERINFO() functions.
Set pFileInfo to point to a block of memory allocated by the caller.
Set pNbrFiles to point to the number of ctFILINF structures that can fit into the pFileInfo buffer.
A successful call to ctGetOpenFiles() sets pNbrFiles to point to the number of ctFILINF structures that were written to the pFileInfo buffer.
When retrieving the FairCom Server's list of open files, the ctFILINF structure's status field is set to the user count for the file. When retrieving a particular connection's list of open files, the status field is set to that user's user file number for the file.
Note that the user file number can contain the following special negative values if the file has been blocked by the FairCom DB file block operation:
If the specified buffer size is too small to hold the names of all open files, *pNbrFiles is set to the number of ctFILINF structures required to hold all the names of all open files, and ctGetOpenFiles() returns error VBSZ_ERR (153, buffer too small).
A successful call to ctGetOpenFiles() fills the memory block with an array of ctFILINF structures.
Note: The file name is stored in the pFileInfo buffer as a null-terminated string and is not padded to the full length of the filnam field. A filename is followed by a padding byte if necessary to ensure that the next ctFILINF structure in the buffer is aligned on a two-byte boundary.
Only a user who is a member of the ADMIN group can call this function. If a user who is not a member of the ADMIN group calls this function, it returns error LADM_ERR (589, member of ADMIN group required).
Return Values
Symbolic Constant |
|
Explanation |
NO_ERROR |
0 |
No error |
VBSZ_ERR |
153 |
Buffer too small |
LADM_ERR |
589 |
Member of ADMIN group required |
See FairCom DB Error Codes for a complete listing of valid error values.
Example
For example code showing how to find the address of a subsequent ctFILINF structure in the output buffer, see the function ictadmnListOpenFiles() in ctadmn.c.
See also
ctGetOpenFilesXtd, ctGetFileUsers, ctGetFileLocks