home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume26
/
modempool
/
part01
/
poolstat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-05
|
2KB
|
69 lines
/********************************************************************
*
* Module: @(#)poolstat.c 4.2 92/04/16
*
* Description:
* Lists status of all callback lines, uses the server data base file
* calltmp
*
* Revision:
* Ver Date By Reason
* --- ---- -- ------
* 1 910118 Lars Berntzon Created
*
********************************************************************/
static char SccsId[] = "@(#)poolstat.c 4.2 92/04/16";
#include <stdio.h>
#include "modempool.h"
main()
{
#ifdef RLOGIN
static char headfmt[] = "%-15s %-5s %-10s %-15s %-5s %-8s %s\n";
static char realfmt[] = "%-15s %-5d %-10s %-15s %-5d %-8s %s\n";
#else
static char headfmt[] = "%-15s %-5s %-10s %-15s %-5s %-8s\n";
static char realfmt[] = "%-15s %-5d %-10s %-15s %-5d %-8s\n";
#endif
struct slot slot;
char *status;
int fd;
if ((fd = open(SERVERDB, 0)) < 0) {
fprintf(stderr, "failed to open server database\n");
exit(1);
}
printf(headfmt, "LINE", "PID", "STATUS", "PHONE", "BAUD", "NAME"
#ifdef RLOGIN
,"HOST"
#endif
);
while(read(fd, &slot, sizeof slot) == sizeof slot) {
if (kill(slot.pid, 0) >= 0) {
switch (slot.status) {
case SLOT_FREE:
status = "free";
break;
case SLOT_BUSY:
status = "busy";
break;
case SLOT_LOGIN:
status = "login";
break;
case SLOT_FAULT:
status = "fault";
break;
default:
status = "(unknown)";
}
printf(realfmt, slot.line, slot.pid, status,
slot.phone, slot.baud, slot.name
#ifdef RLOGIN
,slot.host
#endif
);
}
}
}