// malloc_set.c
// $Id: malloc_set.c,v 1.1.1.1 2007/09/19 05:49:54 sendan Exp $
// masashi shimakura


#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 malloc_set(void)
{
int count;

/* selects data base */
if((gd.db_select=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
/* bcc seting use */
if((gd.on_bcc=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
/* cron onoff set */
gd.cron_onoff = 0;
/*  postgres socket */
if((gd.pg.postgres_data=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
if((gd.pg.pg_webserver=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
/* mysql socket */
if((gd.mysql.mysql_server=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
if((gd.mysql.mysql_username=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
if((gd.mysql.mysql_password=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
if((gd.mysql.mysql_db=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}

/*  my_sock */
if((gd.ms.ip_addr=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
if((gd.ms.chport=(char*)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}

/*  file_path */
if((gd.fp.lock_path=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.fp.clock_path=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.fp.file_conf=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.fp.errlog=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.fp.connectlog=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}

/*  mail_data */
if((gd.md.ch_MailFrom=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.md.ch_MailRcptTo=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.md.ch_MailServ=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.md.ch_MailCc=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}

#ifdef SIGNATURE_MODE
/* Mail Signature */
if((gd.sig.sig_stat=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}
if((gd.sig.sig_filename=(char*)calloc(BUF_SLEN, sizeof(char)))==NULL){exit(1);}

if((gd.sig.sig_data=(char **)malloc(sizeof(char *) * (SIG_MAXLEN + 2)))==NULL){exit(1);}
for(count = 0; count <= (SIG_MAXLEN + 2); count++){
   if((gd.sig.sig_data[count]=(char *)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
   }
#endif

// 20090821 sitarより移植
if((gd.fi.midump_filename = (char *)calloc(BUF_SLEN, sizeof(char)))==NULL){ exit(1);}
if((gd.fi.midump_filename_2 = (char *)calloc(BUF_SLEN, sizeof(char)))==NULL){ exit(1);}

if((gd.td.middle_name=(char **)malloc(sizeof(char *) * (gd.td.midcount + 2)))==NULL){exit(1);}
if((gd.td.middle_id=(char *)malloc(sizeof(char)*(gd.td.midcount + 2)))==NULL){exit(1);}
for(count = 0; count <= gd.td.midcount; count++){
   if((gd.td.middle_name[count]=(char *)calloc(IP_LEN, sizeof(char)))==NULL){exit(1);}
   gd.td.middle_id[count] = 0;
   }


return 0;
}





