#!/afs/athena/contrib/perl/p # # File: nntpgroups - list all the groups that match the group pattern given # $Header: /afs/sipb/contrib/perl/nntp/RCS/nntpgroups,v 1.1 1992/09/17 04:11:52 ckclark Exp $ # # KOPYKNOT (K) 1991 Free Knoware Foundation, Ink. # # This file is part of Randall's NNTP grep-n'-fetch-it utilites. # # NNTP grep-n'-fetch-it is free software. You can redistribute it and # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation or not. That's what makes # this a Kopyknot. You can use this code for any purpose whatsoever. # If you can make a dime off it, great. I'm not out to stop you. If # you want to claim you wrote it, great. It ain't up to me to blow your # cover. Go for it. # # NNTP grep-n'-fetch-it is distributed in the hope that it will make # Randall a famous net.personality. It includes ABSOLUTELY NO WARRANTY. # In fact, you should know that this code will probably fail in lots # of different ways on lots of different machines. If you want to fix # the problems, great. If you want to tell me what you changed, great. # If you want me to fix something for you, go screw yourself. I'm busy. # # This Kopyknot was inspired by the GNU Copyleft. I think that Richard # Stallman is a mensch. If I weren't so obsessed by the almighty buck, # I'd try to get a job working for him. If you want more information on # the GNU General Public License, get GNU Emacs, or write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # I hope you don't feel insulted by my parody, Richard. unshift(@INC, "/afs/sipb.mit.edu/contrib/perl"); unshift(@INC, "/afs/sipb.mit.edu/contrib/perl/nntp"); $groups = 0; require('getopts.pl'); require('nntp.pl'); sub usage { die <<"EndoUsage" usage: $0 [-U] [-F ] [-S ] ... Newsgroups may be specified as regular expressions or as simplified group names using the word \"all\" to match any group field example: $0 comp.sys.all - lists all groups beginning with \"comp.sys\" EndoUsage ; } &usage if ! &Getopts("uF:S:"); $opt_u = 1 if $opt_F; # always use .newsrc if specified $opt_F = ($ENV{"HOME"} . "/.newsrc") if ! $opt_F; # open a connection to the news server. program will die if bad connection $server = $opt_S ? &nntp'connect($opt_S) : &nntp'connect; # make a list of each group to scan while ($pat = shift) { foreach $grp (&nntp'list($server, $pat)) { next if $opt_u && ! &nntp'newsrc_get($opt_F, $grp, 0); print "$grp\n"; $groups = 1; } } $! = 1; # exit with status 1 if no groups die "No groups matched.\n" if (! $groups);