/*
 * A quad hack to read an active file, and update the uunews: tree
 * with .next files that match it.
 *
 * Thanks to Mike Meyer (mwm@contessa.phone.net)
 */

parse arg activefile

/* Verify we've got something to work with */
if activefile = "" then do
	say "usage: active2next <activefile>"
	exit 10
	end

/* Go fetch stuff via nntp */
address command 'nntpxfer' '$NNTPSERVER' activefile 'paranoid'

/* Get the file to process */
if ~open(active, activefile, 'Read') then do
	say "No active file!? Fix this, and try again!"
	exit 10
	end

/* Now do it, one line at a time */
do while ~eof(active)
	parse value readln(active) with group hi . .
	if hi = "" then iterate
	group = translate(group, "/", ".")
	dir = 'uunews:'group
	if ~exists(dir) then iterate
	address command 'echo' (hi + 1) '>'dir'/.next'
	end
