#ifndef	__MDAMODULE_H__
#define	__MDAMODULE_H__

# ifdef __cplusplus
extern "C" {
# endif

#define	MOD_STATUS_OK			0
#define	MOD_STATUS_DISCONNECTED	1
#define	MOD_STATUS_SHUTDOWN		2

#define	uint8_t	unsigned char

typedef struct mod_config_s {
	char *username;
	char *password;
	char *database;
	char *host;
	char *port;
	char *connectionstring;
	char *ssl_key;
	char *ssl_cert;
	char *ssl_ca;
	char *ssl_capath;
	char *ssl_cipher;
	long version;
	int use_transactions;
} mod_config;

typedef struct mod_result_s {
	struct	mod_result_s	*next;
	char	*columnvalue;
} mod_result;

typedef	struct Databaseinfo_s {
	struct	Databaseinfo_s	*next;
	struct	Databaseinfo_s	*previous;
	char	*tablename;
	char	*fieldname;
	char	*type;
	char	*len;
	int	nullable;
	int	_unsigned;
} Databaseinfo;

typedef struct mod_info_s {
	char *version;
	char *transaction;
	uint8_t upsert;
} mod_info;

int	mod_init ();
int	mod_exit();
int	mod_connect (void *handle);
int	mod_disconnet (void *handle);
int	mod_getlasterror (void *handle);
char	*mod_geterrorstring (void *handle);
int	mod_executesql (void *handle, char *query);
char	*mod_add_value (void *handle, char *sqlstring, size_t maxlen);
void	*mod_create (mod_config *cfg);
void	mod_freeresult (void *handle);
void	*mod_querysql (void *handle, char *sqlstring, int *returncode);
int	mod_destroy (void *handle);
uint8_t	mod_get_status (void *handle);
void	mod_set_status (void *handle, uint8_t status);
uint8_t mod_add_column (void *handle, char *tablename, char *columnname, char *type, char *len, uint8_t nullable, int _unsigned, int command);
Databaseinfo *mod_get_databaseinfo (void *handle);
void	mod_free_databaseinfo (Databaseinfo *dbinfo);
int	mod_get_info (void *handle, mod_info *modinfo, int modinfolen);
void	mod_reconnect (void *handle);

# ifdef __cplusplus
}
# endif

#endif

