#ifndef __DB_ADAPTOR_H
#define __DB_ADAPTOR_H

#include "mysql.h"
#include "errmsg.h"
#include <dirent.h>

#ifndef _T_TYPE
#define _T_TYPE

typedef unsigned char 	u8;
typedef unsigned short 	u16;
typedef unsigned int 	u32;
typedef unsigned long 	DWORD;
typedef unsigned long long u64;

#endif

#define MAX_DB_CONN	 4
#define DB_NAME_LEN      32
#define DB_PWD_LEN       16
#define INVALID_DB_LINK_ID 0xFF

typedef struct db_link
{
	u8 	enable;
	u8 	role; 		/*1=master, 0=slave */
	u8 	conn_status; 	/*0=not connected, 1=connected */
	char	str_host_ip[16];
	u32	host_ip;
	u16 	host_port;
	char	db_name[DB_NAME_LEN];
	char	client_name[DB_NAME_LEN];
	char	client_pwd[DB_PWD_LEN];
	MYSQL 	*db_conn;	
}_db_link;

typedef struct db_cfg
{
	u8	  total_active_links;
	u8	  current_working_link_id;
	u8     prefix_file_created;
	_db_link  db_link[MAX_DB_CONN];
}_db_cfg;


#endif
