#ifndef lint
static char *RCSid = "$Header: /sequent2/empire/EMP/player/commands/RCS/ledg.c,v 1.8 89/09/16 15:56:14 mr-frog Exp $";
#endif /* not lint */

/*
 * ledg.c
 *
 * get a report of the current ledger
 * (loans from and to other countries)
 *
 * from PSL Empire, 1985
 */

#include "misc.h"
#include "loan.h"
#include "file.h"
#include "xy.h"
#include "nsc.h"
#include "nat.h"

ledg()
{
	extern	char *argp[];
	struct	nstr_item nstr;
	struct	lonstr loan;
	int	nloan;

	if (!snxtitem(&nstr, EF_LOAN, argp[1]))
		return RET_SYN;
	pr(fmt("\n... %s Ledger ...\n", cname(cnum)));
	nloan = 0;
	while (nxtitem(&nstr, (char *)&loan)) {
		if (disloan(nstr.cur, &loan) > 0)
			nloan++;
	}
	if (!nloan)
		pr("No loans found\n");
	else
		pr(fmt("%d loan%s outstanding.\n", nloan, splur(nloan)));
	return RET_OK;
}
