home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************/
- /* File: ULIST.C */
- /* */
- /* Function: List all users that are currently logged into the */
- /* default server, and some useful stats (only if */
- /* calling user has console operator rights). */
- /* */
- /* Usage: ulist */
- /* */
- /* Functions Called: GetPreferredConnectionID */
- /* GetDefaultConnectionID */
- /* SetPreferredConnectionID */
- /* GetPrimaryConnectionID */
- /* ISShellLoaded */
- /* GetConnectionNumber */
- /* GetConnectionInformation */
- /* GetConnectionsUsageStatistics */
- /* */
- /***************************************************************************/
- #include <conio.h>
- #include <dos.h>
-
- #ifndef TURBOC
- #include <search.h>
- #endif
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
-
- #include "netware.h"
-
- #define FALSE 0
- #define TRUE (!FALSE)
-
- static char *days_of_week[] = { "Sun" , "Mon" , "Tue" ,
- "Wed" , "Thu" , "Fri" ,
- "Sat" };
-
- /**********************************************************************/
-
- void main()
- {
- unsigned int station;
- long object_id;
- int object_type;
- char object_name[OBJECT_LENGTH];
- char logintime[7];
- int thisone;
- long systemelapsedtime;
- double bytesread,byteswritten;
- long totalrequestpackets;
- char c;
- int prefserver;
- int thisserver;
-
- if (IsShellLoaded() != SUCCESS)
- {
- printf("*** No netware shell loaded ***\n");
- exit(255);
- }
-
- if ((prefserver = GetPreferredConnectionID()) == 0)
- {
- if ((thisserver = GetDefaultConnectionID()) == 0)
- thisserver = GetPrimaryConnectionID();
- SetPreferredConnectionID( thisserver );
- }
- else
- thisserver = prefserver;
-
- if( ( thisone=GetConnectionNumber() ) == 0)
- {
- printf("*** No connection number found ***\n");
- if (thisserver != prefserver) /* reset preferred server */
- SetPreferredConnectionID( prefserver );
- exit(255);
- }
-
- printf(" ---Login----");
- printf(" -----file bytes------ request\n");
- printf("conn User Name day time");
- printf(" read written packets\n");
- printf("==================================");
- printf(" ===============================\n");
-
- /* Here, we loop through all the possible stations (connections). */
-
- for (station=1; station<100; station++)
- {
- GetConnectionInformation( station , object_name,
- &object_type,&object_id,
- (byte *)logintime);
- if (object_name[0]!=0)
- {
- if (thisone==station) c='*'; else c=' ';
- printf(" %2u %c%-16s %-3s %02d:%02d:%02d",
- station , c , object_name ,
- days_of_week[ logintime[6] ],
- logintime[3],logintime[4],logintime[5] );
- if ( GetConnectionsUsageStatistics( station,
- &systemelapsedtime ,
- &bytesread,&byteswritten,
- &totalrequestpackets ) == 0)
- printf(" %-10.0f %10.0f %7ld\n",
- bytesread,byteswritten,totalrequestpackets);
- else
- printf("\n");
-
- }
- }
-
- if (thisserver != prefserver) /* reset preferred server */
- SetPreferredConnectionID( prefserver );
- }
-