/* ned.c - DECUS C count number of entries in directories on RSX */
/* Number of Entries in Directory */

#include <stdio.h>
#include <algol68.h>

FILE *	file;
extern int $$ferr;
int	dirbuf[8];
#define ENTSIZ 16
char	nambuf[100];

panic(s)
char *	s;
BEGIN
	error("\7$$ferr=%oo %s",$$ferr,s);
END

main()
BEGIN
register int count;

	IF	( ! (file=fwild("[0,0]*.dir;*","rnu")) )
	THEN	panic("can't understand wild string");
	FI
	WHILE	(fnext(file))
	DO	count = 0;
		WHILE	(fget(dirbuf,ENTSIZ,file))
		DO	IF	(*dirbuf)
			THEN	count++;
			FI
		OD
		IF	( ! feof(file) )	/* only error allowed is EOF */
		THEN	count = -9999;
		FI
		printf("%d\t%s\n",count,fgetname(file,nambuf));
	OD
END

/* end: ned.c */
