
#include<stdio.h>
#include<unistd.h>
#include<netinet/in_systm.h>
#include<netinet/in.h>
#include<string.h>
#include<stdlib.h>
#include<pthread.h>

#include"zither.h"

extern global_data_t gd;




int private_malloc_set(private_data_t *pd)
{
int count = 0;

if((pd->getdata = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}

if((pd->rec.user = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.user_org = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.com = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.data = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.def_user = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.info = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.minfo = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.tinfo = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->rec.ver = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}

if((pd->file.lock_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.clock_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.bat_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.scan_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.conf_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.stat_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.cronfile_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->file.cronlist_filename = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}

if((pd->mail.server = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.block = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.from = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.rcptto = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.cc = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.rcptto_org = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.cc_org = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->mail.priority = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}

if((pd->life.swap1 = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.swap4 = (char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.bat_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.scan_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.conf_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.stat_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.cronfile_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.cronlist_stat=(char *)calloc(BUF_DEFLEN, sizeof(char)))==NULL){exit(1);}
if((pd->life.in_life = (long int *)malloc(LIFE_HI * sizeof(long int)))==NULL){exit(1);}

for(count = 0; count < LIFE_HI; count++){
   pd->life.in_life[count] = 0; 
   }

pd->life.cancel = 0;

return 0;
}





int private_malloc_free(private_data_t *pd)
{

free(pd->getdata);

free(pd->rec.user);
free(pd->rec.user_org);
free(pd->rec.com);
free(pd->rec.data);
free(pd->rec.def_user);
free(pd->rec.info);
free(pd->rec.minfo);
free(pd->rec.tinfo);
free(pd->rec.ver);

free(pd->file.lock_filename);
free(pd->file.clock_filename);
free(pd->file.bat_filename);
free(pd->file.scan_filename);
free(pd->file.conf_filename);
free(pd->file.stat_filename);
free(pd->file.cronfile_filename);
free(pd->file.cronlist_filename);

free(pd->mail.server);
free(pd->mail.block);
free(pd->mail.from);
free(pd->mail.rcptto);
free(pd->mail.cc);
free(pd->mail.rcptto_org);
free(pd->mail.cc_org);
free(pd->mail.priority);

free(pd->life.swap1);
free(pd->life.swap4);
free(pd->life.bat_stat);
free(pd->life.scan_stat);
free(pd->life.conf_stat); 
free(pd->life.stat_stat);
free(pd->life.cronfile_stat);
free(pd->life.cronlist_stat);

free(pd->life.in_life);

return 0;
}





