Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

USERLIST

Track user information for each connection.

Declaration

CTERR USERLIST(pCOUNT pc);

Description

pc - Pointer to an array of type COUNT. You must allocate this array. Make it large enough to hold the maximum allowed connections to your server plus 1. The function will fill this array with task IDs of connected users. The first element is set to the size of the list. I.E. if there are 27 users, there will be 28 items in the array. The first number (element 0) will be 27 followed by 27 task IDs (elements 1-27).

USERLIST() fills out a passed in array of task IDs (of type COUNT) for users connected to the server. The first element is the number of users or the length of the list. The function returns any errors it hits or 0 on success. For each task ID in the list you can call USERINFO() (USERINFOX, USERINFOX) to get additional information about that connected user.

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

#include "ctreep.h" /* c-tree Plus Application Header File */

#ifdef PROTOTYPE

pTEXT elapsed(LONG ct, LONG ut, pTEXT buf)

#else

pTEXT elapsed(ct, ut, buf)

LONG ct, ut;

pTEXT buf;

#endif

{

LONG sec;

if (ut && ut != -1L && ct >= ut) {

sec = (ct - ut) % 60;

ut = (ct - ut) / 60L;

sprintf(buf, "%3d:%02d", ut, sec);

}

else

ctrt_strcpy(buf, " – ");

return(buf);

}

#ifdef PROTOTYPE

NINT main(NINT argc, pTEXT argv[])

#else

NINT main(argc, argv)

NINT argc;

TEXT argv[];

#endif

{

COUNT clist[USRLSTSIZ];

USRPRF ui;

NINT i;

COUNT RetVal;

LONG curtim;

TEXT buf1[16], buf2[16];

if (argc != 4)

{

printf("c-treeACE Users List Utility\n");

printf("Usage:\n");

printf("%s <server_name> <user_name> <password>", argv[0]);

exit(1);

}

#ifdef ctTHRDS

if (ctThrdInit(3, 0L, NULL) != 0)

{

printf("Unable to initialize threading\n");

exit(1);

}

#endif

printf("Getting users connected to %s...\n", argv[1]);

RetVal = InitISAMXtd(16, 16, 16, 16, 0, argv[2], argv[3], argv[1]);

if (RetVal)

{

printf("Error %d connecting to server\n", RetVal);

}

else

{

if (USERLIST(clist))

{

printf("Could not get list of attached clients\n");

}

if (clist[0] == 0)

{

printf("No clients attached\n");

}

printf("Task::UserID::NodeName::Open Files::Logon Time::Tran Time::Rqst Time::Rqst#\n");

for (i = 1; i <= clist[0]; i++)

{

if (USERINFO(clist[i], &ui) || !ui.ulogtim)

continue;

curtim = ui.ucurtim;

printf("%d::%s::%s::%d::disappointed:%s)::disappointed:%s)::disappointed:%s) %s::%d %s\n", ui.utaskid, ui.uname, ui.unodnam, ui.unbrfil, elapsed(curtim, ui.ulogtim, buf1), elapsed(curtim, ui.utrntim, buf1), elapsed(curtim, ui.urqstim, buf2), (ui.uactflg ? "InProcess" : "NoRequest"), ui.urqstfn, ui.urqst);

}

printf("\n");

CloseISAM();

printf("Session Completed.");

}

#ifdef ctTHRDS

ctThrdTerm()

#endif

}

See Also

TOCIndex