(c) 1992 Heiko W.Rupp hwr@pilhuhn.ka.sub.org
uusnap is a tool to display the activities of the connected
Put a file uusnap.systems in NEWCONFIGDIR (see Makefile), in which
the systems, you want to monitor are listed, one on a single line.
The sequence of the files there determine the sequence of the
At the moment it only works with taylor config and taylor dirs
compile it form the Makefile or:
cc -c -g -pipe -O -I. -I. -DNEWCONFIGLIB=\"/usr/local/lib/uucp\" uusnap.c
For this, uusnap.[ch] must be in the same directory as uucp.h and so.
uusnap must have read access to SPOOLDIR/.Status in order to work.
#define MAXSYS 30 /* maximum number of systems */
#define WAIT_NORMAL 10 /* wait period if noone is talking */
#define WAIT_TALKING 2 /* refresh display every second if */
/* someone is talking with us */
char uusnap_rcsid
[] = "$Id: uusnap.c,v 1.1 1993/08/04 19:31:43 jtc Exp $";
extern char *ctime(time_t*);
char sysname
[10]; /* name of the system to watch */
char *statfile
; /* name of its status file */
char *spooldir
; /* root of its spooldir */
int in
; /* number of unprocessed in-files */
int out
; /* number of files to send them */
time_t last
; /* last poll time */
time_t next
; /* time of next poll */
time_t lastidir
; /* time of last in-spooldir access */
time_t lastodir
; /* time of last outgoing spd acc */
time_t laststat
; /* time of last status file access */
int status
; /* status of the system */
int num_retries
; /* number of retries */
struct sysInfo Systems
[MAXSYS
];
/* I have extend the system status. If time for the specified system
is Never, I say so. To get this to work, one also should extend
uucico.c. It is not important to do this. With the normal uucico,
const char *azStatus
[] = /* Status codes as defined by uucico */
{ /* listing them here instead of */
"Conversation complete", /* including the appropriate file */
"Port unavailable", /* reduces the size of the executable */
strcpy(filename
,NEWCONFIGLIB
);
strcat(filename
,"/uusnap.systems");
if ((fp
=fopen(filename
,"r"))!=NULL
) {
while (fgets(line
,80,fp
)!=NULL
) {
*(rindex(line
,'\n'))='\0';
strcpy(sys
.sysname
,line
); /* get the name of the system */
strcpy(fn
,SPOOLDIR
); /* get the name of the statusfile */
sys
.statfile
=malloc(strlen(fn
)+1);
strcpy(fn
,SPOOLDIR
); /* get the name of the spooldir */
sys
.spooldir
=malloc(strlen(fn
)+1);
sys
.lastidir
=sys
.lastodir
=0;
Systems
[i
]=sys
; /* get_stat_for_system needs it */
get_stat_for_system(i
); /* now get the system status */
get_inq_num(i
,TRUE
); /* number of unprocessed files */
get_outq_num(i
,TRUE
); /* number of files to send */
fprintf(stderr
,"Can't open %s \n",filename
);
filename
= (char*)malloc(1024);
fprintf(stderr
, "Can't malloc 1024 bytes");
for (sysnum
=0;sysnum
<numSys
;sysnum
++) {
stat(sys
.statfile
,&stbuf
);
if ((time
=stbuf
.st_atime
) > sys
.laststat
) {
get_stat_for_system(sysnum
);
if(display_status_line(sysnum
)==1)
sleep(WAIT_NORMAL
); /* wait a bit */
display_status_line(int sn
)
int sys_stat
,num_retries
,wait
;
printf("%10s ",sys
.sysname
);
time_s
= ctime(&sys
.last
);
printf("%8s ",time_s
); /* time of last poll */
time_s
= ctime(&sys
.next
);
if (sys
.last
== sys
.next
)
printf("%8s ",time_s
); /* time of next poll */
printf("%2d ",sys
.num_retries
);
if (sys_stat
==6) /* system is talking */
printf("\E[7m"); /* reverse video on */
printf("%s",azStatus
[sys
.status
]);
printf("\E[m\n"); /* reverse video off */
printf("\E[;H\E[2J"); /* clear screen */
printf("\E[7muusnap (press CTRL-C to escape)\E[m \n\n");
printf(" System #in #out last next #ret Status\n");
get_inq_num(int num
,char firstTime
)
strcpy(filename
,Systems
[num
].spooldir
);
strcat(filename
,"/X./.");
if ((stbuf
.st_mtime
> Systems
[num
].lastidir
) || (firstTime
)) {
if ((dirp
=opendir(filename
))!=NULL
) {
Systems
[num
].lastidir
=stbuf
.st_mtime
;
fprintf(stderr
,"Can't open %s \n",filename
);
i
-=2; /* correct . and .. */
get_outq_num(int sys
,char firstTime
)
strcpy(filename
,Systems
[sys
].spooldir
);
strcat(filename
,"/C./.");
if ((stbuf
.st_mtime
> Systems
[sys
].lastodir
) || (firstTime
)) {
if ((dirp
=opendir(filename
))!=NULL
) {
Systems
[sys
].lastodir
=stbuf
.st_mtime
;
fprintf(stderr
,"Can't open %s \n",filename
);
i
-=2; /* correct . and .. */
get_stat_for_system(int i
)
stat(sys
.statfile
,&stbuf
);
if (stbuf
.st_atime
> sys
.laststat
) {
if ((fp
=fopen(sys
.statfile
,"r"))!=NULL
) {
sscanf(fn
,"%d %d %ld %d",
stat(sys
.statfile
,&stbuf
);
sys
.laststat
=stbuf
.st_atime
;