#include <string.h>
#include <exec/types.h>
#include <proto/exec.h>
#include "nl.h"

/*------------------------------------------------------------------------*/
// A "real" application should look it up in some config!

#define NODELISTDIR	"Nodelist:"
/// Accomodate max's taste for directories

/*-------------------------------------------------------------------------*/
typedef struct
	{
	ULONG Cost;
	UWORD CallsMade;
	UWORD CallsReceived;
	UWORD SessionSuccess;
	UWORD SessionFailure;
	UWORD CallsBusy;
	UWORD CallsVoice;
	UWORD CallsNoSomething;
	} NodeAccount;

/*-------------------------------------------------------------------------*/
extern void printf(char *,...);
extern void puts(char *);
extern void exit(int);

void main(void);

/*------------------------------------------------------------------------*/
struct Library *NodelistBase;

/*-------------------------------------------------------------------------*/
BOOL call_me(Addr *addr, Extra xtra)
	{
	NodeAccount *acct;

	if(acct = ExtraFind(xtra, addr, ID_ACCT, NULL))
		{
		printf("  %ld:%ld/%ld.%ld\t| %4ld.%02ld  "
				 "%3ld %3ld  "
				 "%3ld %3ld  "
				 "%3ld %3ld %3ld\n",
			addr->Zone, addr->Net, addr->Node, addr->Point,
			acct->Cost/100, acct->Cost%100,
			acct->CallsMade, acct->CallsReceived,
			acct->SessionSuccess, acct->SessionFailure,
			acct->CallsBusy, acct->CallsNoSomething, acct->CallsVoice);
		}

	return TRUE;
	}

/*-------------------------------------------------------------------------*/
void main()
	{
	Extra xtra;

	if(!(NodelistBase = OpenLibrary(TRAPLIST_NAME, TRAPLIST_VER)))
		{
		printf("Can't open library\n");
		exit(5);
		}

	/* First, open the Extra database */

	if((xtra = ExtraOpen(NODELISTDIR)))
		{
		puts("   Node         |    Cost   CO  CI   S+  S-    B   N   V");
		puts("----------------+-----------------------------------------");
		ExtraEnumNode(xtra, call_me, xtra);
/// removed longish explaination at the end of listacct's output

		ExtraClose(xtra);
		}
	else	
		puts("Extra won't open");

	CloseLibrary(NodelistBase);
	}

/*-------------------------------------------------------------------------*/
/* ID: 74.65@2135  Last Changed: 29 Apr 1991 17:26:49 by max */
