#define _GNU_SOURCE
#include <gd.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include "dates.h"
#include "cores.h"
#include "meminfo.h"
#include "gdfonts.h"
#include "gdfontt.h"
#include "gdfontl.h"
#include "gdfontl.h"  
#include "gdfontmb.h" 

//char webpath[50];
#include "image_sizes.h"
#include "webdir.h"
#include "logdir.h"
//#include "logdir.h"
#include "gdcpuday.h"
#include "gdmemday.h"
#include "gdswapday.h"
#include "gdnetday.h"
#include "gdnetmonth.h"

//#ifdef HAVE_LIBPTHREAD
//#include <pthread.h>
//#endif


int main(void) {

	//pthread_t threads[5];
	//int iret[5];

        meminfo(1,memarray1);
        double memsize = memarray1[1] / 1024;
        //meminfo(1,memarray1);
        double swaptotal = memarray1[6] / 1024;


	webdir();
	logdir();
image_sizes(0);
image_sizes(1);
image_sizes(2);
image_sizes(3);
image_sizes(4);

        netmonth();
        netday();
        //printf("ran netday\n");
        cpuday();
        //printf("ran cpuday\n");
        memday(memsize);
        //printf("ran memday\n");
        swapday(swaptotal);



/*
//	iret[0] = pthread_create( &threads[0], NULL, cpuday, NULL);
	iret[1] = pthread_create( &threads[1], NULL, memday, memsize);
	iret[2] = pthread_create( &threads[2], NULL, swapday, swaptotal);
//	iret[3] = pthread_create( &threads[3], NULL, netday, NULL);
//	iret[4] = pthread_create( &threads[4], NULL, netmonth, NULL);


//	pthread_join( threads[0], NULL);
	pthread_join( threads[1], NULL);
	pthread_join( threads[2], NULL);
//	pthread_join( threads[3], NULL); 
//	pthread_join( threads[4], NULL);


//	printf("Thread 0 returns: %d\n",iret[0]);
	printf("Thread 1 returns: %d\n",iret[1]);
	printf("Thread 2 returns: %d\n",iret[2]);     
//	printf("Thread 3 returns: %d\n",iret[3]);
//	printf("Thread 4 returns: %d\n",iret[4]);
*/

/*
	image_sizes(0);
        image_sizes(1);
        image_sizes(2);
        image_sizes(3);
        image_sizes(4);
	//logdir();
	//printf("ran webdir\n");

	netmonth();
	netday();
        //printf("ran netday\n");
	cpuday();
        //printf("ran cpuday\n");
	memday();
        //printf("ran memday\n");
	swapday();
        //printf("ran swapday\n");
*/

/*
        int pid = fork();
        if (pid == 0){
                image_sizes(0);
		cpuday();

        }else{
                pid = fork();
                if (pid == 0){
                        image_sizes(1);
			memday();
		}else{
                        pid = fork();
                        if (pid == 0){
                                image_sizes(2);
				swapday();
			}else{
                        	pid = fork();
                        	if (pid == 0){
                                	image_sizes(3);
                                	netday();
				}else{
                        		pid = fork();
                        		if (pid == 0){
                                		image_sizes(4);
                                		netmonth();
					}
				}
			}
		}
	}
*/					




	return (0);
}
