#!/bin/csh -f
#**********************************************************************
#         Copyright IBM Corporation 1988,1989 - All Rights Reserved
#         For full copyright information see: 'andrew/config/COPYRITE'
#**********************************************************************
# list-newsgroups dest-location
# ?[POBBRunWarning]
# ?[POBBRunNotice]
%include pobbconfig.defs

%ifdef pobb_NNTPIn

if ($$??0) then
	set EX=$$0
else
	set EX="list-newsgroups"
endif
if ($$#argv < 1) then
	echo "Usage: $$EX destination-file [dest-with-DP-contents]"
	exit(2)
endif
set DPS=0
if ($$#argv >= 2) then
	set DPS=1
endif
set THUD=/usr/tmp/thud.$$$$
rm -f $$THUD
set FUNK=/usr/tmp/funk.$$$$
rm -f $$FUNK
cd ?[PostedNetnewsRoot]
foreach Dir ( ?[arrlist(PostedNetnewsVolRoots)] )
	if ( $$DPS == 0 ) then
	    ws $${Dir} -q -p ?[PostedNetnewsRoot]/ -2 -d "echo %F >> $$THUD"
	else
	    ws $${Dir} -q -p ?[PostedNetnewsRoot]/ -2 -d "echo %F >> $$THUD; echo %F >> $$FUNK; (cat %F/.MS.DirectPost | sed -e 's;^;%F##;') >> $$FUNK 2> /dev/null"
	endif
	set xstat=$$status
	if ( $$xstat != 0 ) then
		echo "Bad status in ws under $${Dir}: $$xstat"
		exit ($$xstat)
	endif
end
cat $$THUD | tr '/' '.' > $$1
set xstat=$$status
if ( $$xstat != 0 ) then
	echo "Bad status storing $${1}: $$xstat"
	exit ( $$xstat )
endif
if ( $$DPS != 0 ) then
	cp $$FUNK $$2
	set xstat=$$status
	if ( $$xstat != 0 ) then
		echo "Bad status storing $${2}: $$xstat"
		exit ( $$xstat )
	endif
endif
rm -f $$THUD $$FUNK
exit (0)

%endif pobb_NNTPIn
