/* netq - print the netq send queue */
/* must be setuid root */
static char jname
[16], printlong
;
static char mach
,visit
[26];
static char netcmd1
[] = NETCMD1
;
static struct stat statbuf
;
static struct direct dirbuf
;
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
[mach
-'a'] == 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
= 'a'; i
<= 'z'; i
++)
if((mach
= gothru(local
,i
)) && !visit
[mach
- 'a']){
senddir
[strlen(senddir
)-1] = mach
;
if(chdir(senddir
) < 0)continue;
while(fread(&dirbuf
,1,sizeof dirbuf
,df
)==sizeof dirbuf
){
|| dirbuf
.d_name
[0] != 'c'
|| dirbuf
.d_name
[1] != 'f'
|| stat(dirbuf
.d_name
,&statbuf
) < 0)
if(mach
!= dirbuf
.d_name
[2])continue;
if(stat(dirbuf
.d_name
,&statbuf
) < 0)continue;
if(!insert(dirbuf
.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
));
"From To Len Code Time Command\n");
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
)
if(more
)printf(" ... more ...\n");
sumb
+= stack
[i
].filesize
;
printf("%d request%s, %ld bytes\n",
sumj
,(sumj
> 1 ? "s" : ""),sumb
);
if(hd
.hd_snfrom
[0] == 0)strcat(hd
.hd_addrfrom
,"Internal");
expandcc(hd
.hd_sttyname
);
cp
= ctime(&statbuf
.st_mtime
);
printf("%-10s %-10s %5ld %s %s %-.27s\n",
hd
.hd_addrfrom
,hd
.hd_addrto
,getsize(&statbuf
),
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
;