#include <oci.h>
#include <stdio.h>
#include <string.h>

/* Helper routines for communications with a database and data definitions for them*/
typedef struct tag_plsql_ShortOCIConn
{
	OCIEnv     *hEnv;
	OCIError   *hErr;
	OCISvcCtx  *hCtx;
	request_rec*r;
	char *err;
} plsql_ShortOCIConn;
typedef struct
{
    char *var_name;
    char *var_val;
} plsql_Vars;
struct _plsql_ProcParam;
typedef struct _plsql_ProcParam
{
    char *name;
    char **value;
    int numvals;
    struct _plsql_ProcParam* next;
}plsql_ProcParam;


#define CONFIG_MODE_SERVER 1
#define CONFIG_MODE_DIRECTORY 2
#define CONFIG_MODE_COMBO 3     /* Shouldn't ever happen. */

#ifndef DEFAULT_PLSQL_CONF
#define DEFAULT_PLSQL_CONF "db.conf"
#endif


typedef struct plsql_DBDirConf
{
    plsql_ShortOCIConn con;
    char *confpath;
} plsql_DBDirConf;

#ifndef MAX_CONF_LINE
#define MAX_CONF_LINE 1024
#endif

#ifndef MAX_DBUNAME
#define MAX_DBUNAME 32
#endif

#ifndef MAX_DBPASSWD
#define MAX_DBPASSWD 64
#endif

#ifndef MAX_DBALIAS
#define MAX_DBALIAS 256
#endif

typedef struct plsql_dbalias
{
    regex_t *url_match;
    char *config_match;
} plsql_dbalias;
typedef struct plsql_svr_cfg
{
//    table *expanded_dir_dbs;
    array_header *dir_dbs;
}plsql_svr_cfg;
typedef struct plsqlcfg {
    char *dbAl;
    char *uName;
    char *uPasswd;
    int	 errorlevel;
    char *loc;                  /* Location to which this record applies. */
} plsqlcfg;

/*Globals*/
/*functions*/
void plsql_cleanupConn(plsql_ShortOCIConn *con);
/* Getting DB Connection info*/
/* setup environment for a PL/SQL call*/
int plsql_ConnectDB(plsql_ShortOCIConn *con,text *uname,text *passwd,text *dbal);
int plsql_execute(plsql_ShortOCIConn *con,text *stmt);
int plsql_output(plsql_ShortOCIConn *con);
int plsql_headers(plsql_ShortOCIConn *con);
/*plsql_ProcParam* plsql_GetProcDesc(plsql_ShortOCIConn *con,const char *pname,int *ret);*/
