/* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Adams. * * originally by RJKing WECo-MG6565 May 83 * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1988 The Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)uusnap.c 5.11 (Berkeley) 02/02/91"; #endif /* not lint */ #include "uucp.h" #include #ifdef NDIR #include "ndir.h" #else #include #endif #include #define NSYSTEM 300 /* max # of systems queued */ #define CMDSLEN 5 /* Length of trailer */ #define DATALEN 5 /* Length of trailer */ #define XEQTLEN 5 /* Length of trailer */ #define NUMCTRS 3 /* # file types to count */ #define CMDTYPE 0 /* Index into scnt.cntr */ #define DATTYPE 1 /* Index into scnt.cntr */ #define XEQTYPE 2 /* Index into scnt.cntr */ struct scnt { /* System count structure */ char name[MAXBASENAME+1]; /* Name of system */ short cntr[NUMCTRS]; /* Count */ char stst[32]; /* STST Message */ time_t locked; /* If LCK..sys present */ int st_type; /* STST Type */ int st_count; /* STST Count */ time_t st_lastime; /* STST Last time tried */ time_t st_retry; /* STST Secs to retry */ }; int sndx; /* Number of systems */ struct scnt sys[NSYSTEM]; /* Systems queued */ int xqtisrunning = 0; main() { register int i, j, nlen = 0; time_t curtime, t; dodir(CMDSDIR, "C.", CMDSLEN, '\0', CMDTYPE); dodir(DATADIR, "D.", DATALEN, '\0', DATTYPE); dodir(XEQTDIR, "X.", XEQTLEN, 'X', XEQTYPE); getstst(SPOOL); time(&curtime); for(i=0; i nlen) nlen = j; for(i=0; i1?"s":" "); else printf(" --- "); if(sys[i].cntr[DATTYPE]) printf("%3.d Data ", sys[i].cntr[DATTYPE]); else printf(" --- "); if(sys[i].cntr[XEQTYPE]) printf("%3.d Xqt%s ", sys[i].cntr[XEQTYPE], sys[i].cntr[XEQTYPE]>1?"s":" "); else printf(" --- "); if(*sys[i].stst == '\0' || sys[i].locked > sys[i].st_lastime) { if(sys[i].locked) printf("LOCKED\n"); else printf("\n"); continue; } printf("%s ", sys[i].stst); /* decide if STST info is worth pursuing */ if (-t < ONEDAY*2 && (sys[i].st_count == 0 || sys[i].st_type == SS_WRONGTIME || (sys[i].st_type == SS_INPROGRESS && sys[i].locked))) { printf("\n"); continue; } t = (sys[i].st_lastime +sys[i].st_retry) - curtime; if (-t < ONEDAY*2 && sys[i].st_type != SS_FAIL) t = 0; if (sys[i].st_count > MAXRECALLS) printf("at MAX RECALLS"); else if (-t >= ONEDAY*2) printf("%ld days ago", (long)-t/ONEDAY); else if (t <= 0) printf("Retry time reached"); else if (t < 60) printf("Retry time %ld sec%s", (long)(t%60), (t%60)!=1? "s": ""); else printf("Retry time %ld min%s", (long)(t/60), (t/60)!=1? "s": ""); if(sys[i].st_count > 1) printf(" Count: %d\n", sys[i].st_count); else printf("\n"); } if (xqtisrunning) printf("\nUuxqt is running\n"); exit(0); } dodir(dnam, prfx, flen, fchr, type) char *dnam, *prfx; int flen; char fchr; int type; { register struct direct *dentp; register DIR *dirp; register int i, fnamlen, plen; char fnam[MAXNAMLEN+1]; plen = strlen(prfx); if(chdir(dnam) < 0) { perror(dnam); exit(1); } if ((dirp = opendir(".")) == NULL) { perror(dnam); exit(1); } while((dentp = readdir(dirp)) != NULL) { if(*dentp->d_name == '.') continue; if(strncmp(dentp->d_name, prfx, plen) != SAME) { fprintf(stderr, "strange file (%s) in %s\n", dentp->d_name, dnam); continue; } strcpy(fnam, &dentp->d_name[plen]); fnamlen = strlen(fnam); if(flen > 0) { fnamlen -= flen; fnam[fnamlen] = '\0'; fnamlen = MAXBASENAME; /* yes, after = '\0'*/ } else { for(; fnamlen>0; --fnamlen) { if(fnam[fnamlen] == fchr) { fnam[fnamlen] = '\0'; break; } } fnamlen = MAXBASENAME; } for(i=0; i= NSYSTEM) { sndx = NSYSTEM-1; fprintf(stderr,"Too many system names.\n"); } } } closedir(dirp); } getstst(sdir) char *sdir; { register int i, csys; register char *tp; char fnam[MAXNAMLEN+1], buff[128]; register struct direct *dentp; register DIR *dirp; register FILE *st; struct stat stbuf; long atol(); if (chdir(sdir) < 0) { perror(sdir); exit(1); } if ((dirp = opendir(LOCKDIR)) == NULL) { perror(sdir); exit(1); } while ((dentp = readdir(dirp)) != NULL) { if (strcmp(&dentp->d_name[5], X_LOCK) == SAME) { xqtisrunning++; continue; } if(strncmp(dentp->d_name, "LCK..", 5) == SAME) { if(strncmp(&dentp->d_name[5], "tty", 3) == SAME || strncmp(&dentp->d_name[5], "cul", 3) == SAME) continue; strcpy(fnam, dentp->d_name); for(csys=0; csysd_name == '.') continue; strcpy(fnam, dentp->d_name); for(csys=0; csys