Added files in imontty.
This commit is contained in:
parent
20d78a8145
commit
2c2477711c
|
@ -0,0 +1,20 @@
|
|||
0.5 - 03.02.97
|
||||
______________
|
||||
|
||||
rewrite from scratch: Use C instead of C++
|
||||
no more options supported
|
||||
|
||||
|
||||
0.4 - 01.12.95
|
||||
--------------
|
||||
|
||||
adapt to new isdninfo format of isdn4linux 0.7
|
||||
|
||||
|
||||
0.3 - 25.08.95
|
||||
--------------
|
||||
|
||||
Option -i to get alternative info device than /dev/isdninfo
|
||||
Add continuous output similar to top(1).
|
||||
Wrote manpage
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# tty line ISDN status monitor
|
||||
#
|
||||
# (c) 1995-97 Volker Götz
|
||||
#
|
||||
# $Id: Makefile,v 1.1 1997/03/03 04:10:10 fritz Exp $
|
||||
|
||||
ifeq (../.config,$(wildcard ../.config))
|
||||
#
|
||||
# Automatic config with isdn4k-utils
|
||||
#
|
||||
include ../.config
|
||||
MAN8PATH := $(CONFIG_MANDIR)/man8
|
||||
else
|
||||
#
|
||||
# Manual config standalone
|
||||
#
|
||||
CONFIG_SBINDRIR := /sbin
|
||||
MAN8PATH := /usr/man/man8
|
||||
endif
|
||||
|
||||
CCFLAGS=-O2
|
||||
#CCFLAGS=-I$(ISDN_INCLUDE) -g
|
||||
|
||||
# nothing to change behind this line
|
||||
|
||||
PROGS=imontty
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
imontty: imontty.c imontty.h
|
||||
cc $(CCFLAGS) -o imontty imontty.c
|
||||
|
||||
rootperm:
|
||||
@if [ `id -u` != 0 ] ; then \
|
||||
echo -e "\n\n Need root permission for (de)installation!\n\n"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
install: $(PROGS) rootperm
|
||||
install -s -o 0 -g 0 -m 0755 $(PROGS) $(CONFIG_SBINDIR)
|
||||
|
||||
uninstall: rootperm
|
||||
for i in $(PROGS) ; do rm -f $(CONFIG_SBINDIR)/$$i; done
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROGS) *~
|
||||
|
||||
distclean: clean
|
||||
|
||||
#
|
||||
# dummy for isdn4k-utils package
|
||||
#
|
||||
config:
|
|
@ -0,0 +1,52 @@
|
|||
* tty line ISDN status monitor
|
||||
*
|
||||
* (c) 1995-97 Volker Götz
|
||||
*
|
||||
* $Id: README,v 1.1 1997/03/03 04:10:11 fritz Exp $
|
||||
|
||||
imontty 0.5
|
||||
===========
|
||||
|
||||
This is version 0.5 of imontty, a handy program to print out the
|
||||
status of all ISDN lines of the isdn4linux package.
|
||||
|
||||
|
||||
INSTALLATION:
|
||||
-------------
|
||||
|
||||
Check SBINPATH in the Makefile for the correct path where to
|
||||
install the binary.
|
||||
|
||||
To build the binary just type
|
||||
|
||||
make
|
||||
|
||||
To install the binary in its final location type
|
||||
|
||||
make install
|
||||
|
||||
|
||||
USAGE:
|
||||
------
|
||||
|
||||
To print the status of the ISDN lines type "imontty". No command
|
||||
line options are supported. The output should look like this:
|
||||
|
||||
ISDN channel status:
|
||||
|
||||
Channel Usage Type Number
|
||||
----------------------------------------------------------------------
|
||||
line0 Out Net S7900734
|
||||
line0 Off
|
||||
|
||||
|
||||
Usage is one of Off(line), Out(going), In(coming) or Excl(usive).
|
||||
|
||||
Type is one of raw (raw device), Modem (modem/tty emulation), Net
|
||||
(IP interface), Voice (voice call) or Fax (fax transmission).
|
||||
|
||||
Number is either the called partys number (outgoing) or the
|
||||
calling party number (incoming).
|
||||
|
||||
If you have any suggestions or error reports pleas let me know
|
||||
via email to volker@oops.franken.de.
|
|
@ -0,0 +1,126 @@
|
|||
/* tty line ISDN status monitor
|
||||
*
|
||||
* (c) 1995-97 Volker Götz
|
||||
*
|
||||
* $Id: imontty.c,v 1.1 1997/03/03 04:10:12 fritz Exp $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <linux/isdn.h>
|
||||
#include "imontty.h"
|
||||
|
||||
void scan_str(char * buffer, char * field[], int max) {
|
||||
char * buf = buffer;
|
||||
int i;
|
||||
char * token = strtok(buf, "\t");
|
||||
|
||||
for(i=0; i < max; i++) {
|
||||
token = strtok(NULL, " ");
|
||||
if ((field[i] = malloc(strlen(token) * sizeof(char))) != NULL)
|
||||
strcpy(field[i], token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void scan_int(char * buffer, int (*field)[], int max) {
|
||||
char * buf = buffer;
|
||||
int i;
|
||||
char * token = strtok(buf, "\t");
|
||||
|
||||
for(i=0; i < max; i++) {
|
||||
token = strtok(NULL, " ");
|
||||
(*field)[i] = atoi(token);
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
||||
FILE * isdninfo;
|
||||
char buf[IM_BUFSIZE];
|
||||
|
||||
char * idmap[ISDN_MAX_CHANNELS];
|
||||
int chmap[ISDN_MAX_CHANNELS];
|
||||
int drmap[ISDN_MAX_CHANNELS];
|
||||
int usage[ISDN_MAX_CHANNELS];
|
||||
int flags[ISDN_MAX_DRIVERS];
|
||||
char * phone[ISDN_MAX_CHANNELS];
|
||||
|
||||
int i, lines;
|
||||
|
||||
if (!(isdninfo = fopen(PATH_ISDNINFO, "r"))) {
|
||||
fprintf(stderr, "ERROR: Can't open '%s'\n", PATH_ISDNINFO);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_str(buf, idmap, ISDN_MAX_CHANNELS);
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_int(buf, &chmap, ISDN_MAX_CHANNELS);
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_int(buf, &drmap, ISDN_MAX_CHANNELS);
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_int(buf, &usage, ISDN_MAX_CHANNELS);
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_int(buf, &flags, ISDN_MAX_DRIVERS);
|
||||
|
||||
fgets(buf, IM_BUFSIZE, isdninfo);
|
||||
scan_str(buf, phone, ISDN_MAX_CHANNELS);
|
||||
|
||||
fclose(isdninfo);
|
||||
|
||||
printf("\n%s\n\n", "ISDN channel status:");
|
||||
printf("%-20.20s\t%-6.6s%-6.6s%s\n", "Channel", "Usage", "Type", "Number");
|
||||
printf("----------------------------------------------------------------------\n");
|
||||
|
||||
lines = 0;
|
||||
for(i=0; i < ISDN_MAX_CHANNELS; i++)
|
||||
if (chmap[i] >= 0 && drmap[i] >= 0) {
|
||||
|
||||
/* printf("%-20.20s/%i\t", idmap[i], chmap[i]); */
|
||||
printf("%-20.20s\t", idmap[i]);
|
||||
|
||||
if (usage[i] & ISDN_USAGE_OUTGOING)
|
||||
printf("%-6.6s", "Out");
|
||||
else if (usage[i] == ISDN_USAGE_EXCLUSIVE)
|
||||
printf("%-6.6s", "Excl.");
|
||||
else if (usage[i])
|
||||
printf("%-6.6s", "In");
|
||||
else
|
||||
printf("%-6.6s", "Off");
|
||||
|
||||
switch(usage[i] & ISDN_USAGE_MASK) {
|
||||
case ISDN_USAGE_RAW:
|
||||
printf("%-6.6s", "raw");
|
||||
break;
|
||||
case ISDN_USAGE_MODEM:
|
||||
printf("%-6.6s", "Modem");
|
||||
break;
|
||||
case ISDN_USAGE_NET:
|
||||
printf("%-6.6s", "Net");
|
||||
break;
|
||||
case ISDN_USAGE_VOICE:
|
||||
printf("%-6.6s", "Voice");
|
||||
break;
|
||||
case ISDN_USAGE_FAX:
|
||||
printf("%-6.6s", "Fax");
|
||||
break;
|
||||
default:
|
||||
printf("%-6.6s", "");
|
||||
break;
|
||||
}
|
||||
|
||||
if(usage[i] & ISDN_USAGE_MASK)
|
||||
printf("%s\n", phone[i]);
|
||||
else
|
||||
printf("\n");
|
||||
|
||||
if( !(++lines % 2) )
|
||||
printf("\n");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/* tty line ISDN status monitor
|
||||
*
|
||||
* (c) 1995-97 Volker Götz
|
||||
*
|
||||
* $Id: imontty.h,v 1.1 1997/03/03 04:10:12 fritz Exp $
|
||||
*/
|
||||
|
||||
#define PATH_ISDNINFO "/dev/isdninfo"
|
||||
#define IM_BUFSIZE 10 + (22 * ISDN_MAX_CHANNELS)
|
||||
#define IM_VERSION "0.5"
|
Loading…
Reference in New Issue