#include "configutil.h"
#include "mailutil.h"
#include "xutil.h"
#include "scrollutil.h"
#include <stdlib.h>
#include <stdio.h>

xutil		*xutility;
configutil	*configutility;
mailutil 	*mailutility;
scrollutil	*scroller;
int		scrolling=1;

void	parsecmdline(int argc, char *argv[]) {

	char	*argument;

	for (int i=1; i<argc; i++) {
		argument=argv[i];
		if (argument[0]=='-') {
			if (!strncmp(argument,"-noscroll",9)) {
				scrolling=0;
			}
		}
	}
}

void	Exit() {
	delete configutility;
	delete mailutility;
	delete scroller;
	delete xutility;
	exit(0);
}

void	main (int argc, char *argv[]) {

	parsecmdline(argc, argv);

	xutility=new	xutil(argc, argv);
	configutility=new configutil(xutility);
	mailutility=new mailutil(xutility, configutility->first);
	scroller=new scrollutil(xutility, mailutility, &xutility->mainwin, 
				scrolling);

	mailutility->CheckMail();
	scroller->UpdateFaces();
	scroller->DrawFace();
	xutility->Border();

	xutility->MainLoop();
}
