USERINFOX
Track user information for each connection.
Declaration
NINT USERINFOX(pUSRINFX pusrinfx);
Description
In V11.6 and later, FairCom Server tracks the following statistics for each connection:
Note that USERINFOX() also returns the connection information for the calling connection.
Compatibility Note: This feature does not introduce any compatibility issues, however a new client library and new server are required to use the USERINFOX() function. If the new client library is used to connect to an old server, a call to the USERINFOX() function fails with error 170. The behavior of the existing USERINFO() function is unchanged.
USRINFX structure definition:
typedef struct userinfoxprm {
UCOUNT StructVersion; /* [IN] Version of this structure. */
UCOUNT TaskId; /* [IN,OUT] On input, set to the task ID of the
connection whose information is to be returned,
or set it to zero to return the information for
all connections. On output, this field is set to
the number of entries that were written to the
output buffer. */
ULONG UserInfoLength; /* [IN] Size of one connection info entry. */
ULONG OutBufferSize; /* [IN,OUT] On input, set to the size of the
output buffer. On output, holds the number of
bytes written to the output buffer. If the
required size is too small, the function returns
error code VBSZ_ERR and sets OutBufferSize to
the size required to hold information for all
of the connections. */
pTEXT pOutBuffer; /* [OUT] Buffer where the connection info is
returned. */
} USRINFX, *pUSRINFX;
Return Values
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
CTDBRET_OK |
Successful operation. |
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.
Example
int call_USERINFOX (void)
{
pUSRPRFX pupx = NULL;
pUSRPRFX spx;
USRINFX uix;
ULONG outbuflen = 16 * sizeof(USRPRFX);
NINT rc,i;
retry:
/* Allocate output buffer. */
if (!(pupx = (pUSRPRFX) calloc(1,outbuflen))) {
rc = UALC_ERR;
goto err_ret;
}
/* Set structure version. */
uix.StructVersion = USERINFOX_VERS_V01;
/* Set size of information structure. */
uix.UserInfoLength = sizeof(USRPRFX);
/* Get info for all connections. */
uix.TaskId = 0;
/* Set output buffer. */
uix.pOutBuffer = (pTEXT) pupx;
/* Set size of output buffer. */
uix.OutBufferSize = outbuflen;
rc = USERINFOX(&uix);
if (rc) {
if (rc == VBSZ_ERR) {
if (uix.OutBufferSize <= outbuflen) {
/* Unexpected */
rc = PBAD_ERR;
goto err_ret;
}
outbuflen = uix.OutBufferSize;
free(pupx);
pupx = NULL;
goto retry;
}
goto err_ret;
}
/* Loop over connection info entries: */
for (i = 0, spx = (pUSRPRFX) uix.pOutBuffer; i < uix.TaskId; i++, spx++) {
/* spx points to the connection info for the ith entry. */
}
err_ret:
if (pupx) {
free(pupx);
}
return(rc);
}
See Also