Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site arizona.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!arizona!whm
From: whm@arizona.UUCP (whm)
Newsgroups: net.wanted.sources
Subject: Re: local netnews usage statistics
Message-ID: <18207@arizona.UUCP>
Date: Sat, 1-Dec-84 05:37:02 EST
Article-I.D.: arizona.18207
Posted: Sat Dec  1 05:37:02 1984
Date-Received: Sun, 2-Dec-84 03:54:44 EST
References: <772@islenet.UUCP>
Organization: Dept of CS, U of Arizona, Tucson
Lines: 69

Here's an Icon program that does some .newsrc investigations.

					Bill Mitchell
					whm.arizona@csnet-relay
					{noao,mcnc,utah-cs}!arizona!whm
----- Cut Here -----
#
# newscount--read .newsrc files and produce information about them.  Accepts
#  .newsrc files as arguments or reads one on standard input.  Not a sterling
#  example of Icon coding by any means.
#
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