newscount.icn--analyze newsrc files
whm at arizona.UUCP
whm at arizona.UUCP
Sun Aug 28 17:40:01 AEST 1983
Here's an Icon program that reads .newsrc files and cranks out
various sorts of information about them. You may find:
newscount /usr/*/.newsrc
to be entertaining.
Bill Mitchell
whm.arizona at rand-relay
{kpno,ihnp4,mcnc,utah-cs}!arizona!whm
- - - - - - - - - Cut here and run through sh - - - - - - - - - - -
echo x - newscount.1
cat >newscount.1 <<'Funky-Stuff'
.TH NEWSCOUNT 1
.UC 4
.SH NAME
newscount \- read .newsrc files and produce information about them
.SH SYNOPSIS
\fBnewscount\fP file ...
.SH DESCRIPTION
\fInewscount\fP reads each named .newsrc file and produces a count
of the articles read in each group. Two columns of output are
produced, the first column is the name of a group, the second is
the number of articles read in that group. Output is in alphabetical order
by group. If more than one .newsrc file
is named, there is a third column of output of the form \fIs/u\fP where
\fIs\fP the number of .newsrc files that are ``subscribed'' to the group
and \fIu\fP is the number that are ``unsubscribed''.
Groups that have been unsubscribed to in all named .newsrc files
are indicated by a trailing
exclamation point in parentheses. A final line of output indicates
the total number of articles read, the number of groups, and the
number of groups that are currently being subscribed to. If a named
file can not be opened, it is noted, but ignored.
.PP
.SH "SEE ALSO"
readnews(1)
.SH BUGS
\&.newsrc files with multiple entries for newsgroups produce
results that may not be correct.
.PP
newscount works with version 2.10 of B news. It may or may not work
with other versions of B news.
Funky-Stuff
echo x - newscount.icn
cat >newscount.icn <<'Funky-Stuff'
#
# newscount--read .newsrc files and produce information about them
#
record ginfo(number,reading,nsubs,nusubs)
procedure main(a)
digs := '0123456789'
nt := table()
if *a = 0 then
a := [&input]
every f := !a do {
if type(f) ~== "file" then
f := open(f) |
(write("Can't open '",f,"'") & f := open("/dev/null","r"))
while line := read(f) do {
line ? {
group := 1(tab(many(~' ')-1),
sep := (move(1) == (":"|"!"))) | next
tab(upto(digs)) | next
nr := ginfo(count(tab(0)),sep,0,0)
if \nt[group] & *a > 1 then {
nt[group].number +:= nr.number
(nr.reading == nt[group].reading == "!") |
(nt[group].reading := ":")
}
else
nt[group] := nr
if nr.reading ~== "!" then
nt[group].nsubs +:= 1
else
nt[group].nusubs +:= 1
}
}
close(f)
}
nt := sort(nt)
n := g := act := 0
every e := !nt do {
write(left((e[1] ||
((e[2].reading == "!","(!)") | 1("",act+:=1))),20),
right(e[2].number,6),
(*a > 1 & right(e[2].nsubs||"/"||e[2].nusubs,10))|"")
g +:= 1
n +:= e[2].number
}
write("Total of ",n," articles in ",g," groups. ",
act," groups currently active.")
end
procedure count(s)
n := 0
s ? while (n +:= nread(tab(many(~','))),move(1))
return n
end
procedure nread(s)
s ? {
first := tab(upto('-')) &
move(1) &
last := tab(0)
} | (last := first := 0)
return last - first + 1
end
Funky-Stuff
More information about the Comp.sources.unix
mailing list