static char sccsid
[] = "@(#)netq.c 4.2 (Berkeley) %G%";
/* netq - print the netq send queue */
/* must be setuid root */
static char *netq_sid
= "@(#)netq.c 1.5";
/* this is an internal table size -- only STSIZE entries will
static char jname
[16], printlong
;
static char mach
,visit
[MAXINX
];
static char netcmd1
[] = NETCMD1
;
static int hisuid
,sumj
,nsumj
;
static struct stat statbuf
;
hisuid
= uidmask(hisuid
);
if(stat(netcmd
,&statbuf
) >= 0)
if((statbuf
.st_mode
& 07) == 0){
printf("Network is down\n");
else if(stat(netcmd1
,&statbuf
) >= 0)
if((statbuf
.st_mode
& 07) == 0){
printf("Network is down\n");
case '-': printlong
++; break;
default: mach
= lookup(argv
[1]);
if(mach
> 0 && machtype
[chtoinx(mach
)] == 0)mach
= 0;
mach
= gothru(local
,mach
); /* list to directly conn. machine */
fprintf(stderr
,"That machine not directly connected.\n");
senddir
[strlen(senddir
)-1] = mach
;
else for(i
= 0; i
< MAXINX
; i
++)
if((mach
= gothru(local
,inxtoch(i
))) && !visit
[chtoinx(mach
)]){
visit
[chtoinx(mach
)] = 1;
senddir
[strlen(senddir
)-1] = mach
;
if(chdir(senddir
) < 0)continue;
register struct direct
*dp
;
while((dp
= readdir(df
)) != NULL
){
|| stat(dp
->d_name
,&statbuf
) < 0)
if(mach
!= dp
->d_name
[2])continue;
if(stat(dp
->d_name
,&statbuf
) < 0)continue;
if( stptr
>= MAXSENDQ
) {
if(!insert(dp
->d_name
,getsize(&statbuf
))){
printf("Network queue to/thru %s is empty.\n",longname(mach
));
cp
= (char *)&(stack
[0].name
[0]);
sort(cp
,stptr
,sizeof temp
,compar
);
printf("Network queue to/thru %s:\n",longname(mach
));
for(i
= 0; i
< stptr
; i
++){ /* screen size */
strcpy(jname
,stack
[i
].name
);
if(stat(jname
,&statbuf
) < 0)
if(printlong
|| guid(statbuf
.st_uid
,statbuf
.st_gid
) == hisuid
){
printf( "From To Len Code Time Command\n");
else summarize( stack
[i
].filesize
);
if(more
)printf(" ... more ...\n");
if( size
> MAXDAYFILE
) {
if( sumj
!= 0 || nsumj
!= 0 ){
printf("day jobs: %d request%s (%ld bytes)",
sumj
, (sumj
> 1 ? "s" : ""), sumb
);
printf("; night jobs: %d request%s (%ld bytes)",
nsumj
, ( nsumj
> 1 ? "s" : ""), nsumb
);
printf("%d request%s, %ld bytes\n",
sumj
,(sumj
> 1 ? "s" : ""),sumb
);
static char nightheader
= 0;
if(hd
.hd_snfrom
[0] == 0)strcat(hd
.hd_addrfrom
,"Internal");
expandcc(hd
.hd_sttyname
);
cp
= ctime(&statbuf
.st_mtime
);
size
= getsize(&statbuf
);
if(size
>= MAXDAYFILE
&& ! nightheader
){
printf("(> %ld bytes, will only transfer between Midnight and 6AM.)\n", MAXDAYFILE
);
printf("%-10s %-10s %6ld %s %s %-.27s\n",
hd
.hd_addrfrom
,hd
.hd_addrto
,size
,jname
+3,cp
+4,hd
.hd_scmdvirt
);
register struct header
*phd
;
char sbuf
[BUFSIZ
], parmlist
[PARMLIST
];
phd
->hd_code
= phd
->hd_mchto
= phd
->hd_snto
[0] = phd
->hd_sinfile
[0] = 0;
phd
->hd_soutfile
[0] = phd
->hd_srespfile
[0] = phd
->hd_snfrom
[0] = 0;
for(i
=0;i
<20;i
++)phd
->hd_sttyname
[i
] = 0;
phd
->hd_code
= ngetc(fd
);
if(phd
->hd_code
== 0)return;
phd
->hd_mchto
= ngetc(fd
);
phd
->hd_mchfrom
= ngetc(fd
); /* from machine */
phd
->hd_vmajor
= ngetc(fd
);
phd
->hd_vminor
= ngetc(fd
);
ngets(phd
->hd_snto
,NS
,fd
);
ngets(phd
->hd_spasswd
,20,fd
); /* passwd */
ngets(phd
->hd_sinfile
,FNS
,fd
);
ngets(phd
->hd_soutfile
,FNS
,fd
);
ngets(phd
->hd_srespfile
,FNS
,fd
);
ngets(phd
->hd_snfrom
,NS
,fd
);
ngets(phd
->hd_sttyname
,20,fd
);
ngets(sbuf
,BUFSIZ
,fd
); /* lttytime */
ngets(parmlist
,PARMLIST
,fd
); /* jobno */
ngets(sbuf
,BUFSIZ
,fd
); /* timesent */
while((c
= getc(fd
)) != EOF
&& c
!= '\n'){
if(c
== '\\')c
= getc(fd
);
while((c
= getc(fd
)) != EOF
&& c
!= '\n'){
if(c
== '\\')c
= getc(fd
);
if(phd
->hd_scmdvirt
[0] == 0)strcpy(phd
->hd_scmdvirt
,phd
->hd_scmdact
);
sprintf(phd
->hd_addrfrom
,"%c:%s",phd
->hd_mchfrom
,phd
->hd_snfrom
);
sprintf(phd
->hd_addrto
,"%c:%s",phd
->hd_mchto
,phd
->hd_snto
);
if(fread(b
,1,3,fd
) != 3) return(0);
/* read a string s of max length maxlen out of queue file */
if(*s
== '\\')*s
= getc(fd
);
strcpy(stack
[stptr
].name
,f
);
stack
[stptr
++].filesize
= t
;
register struct table
*a
,*b
; {
if(a
->filesize
< b
->filesize
)return(-1);
if(a
->filesize
> b
->filesize
)return(1);
sort(){ /* use this cause qsort doesn't work */
for(i
=0; i
< stptr
-1; i
++)
if(compar(&stack
[i
],&stack
[j
]) > 0)
swap(&stack
[i
],&stack
[j
]);
register struct table
*a
, *b
; {
a
->filesize
= b
->filesize
;
register struct direct
*dp
; {
|| stat( dp
->d_name
, &statbuf
) < 0 )
if( mach
!= dp
->d_name
[2] )
if( stat( dp
->d_name
, &statbuf
) < 0 )
if( printlong
|| guid( statbuf
.st_uid
, statbuf
.st_gid
) == hisuid
)
summarize( getsize( &statbuf
) );
} while((dp
= readdir(df
)) != NULL
);