Direct database side of things implemented
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
#ifndef __CONNECTION_H__
|
||||
#define __CONNECTION_H__
|
||||
#ifndef H__DB_CONNECTION__
|
||||
#define H__DB_CONNECTION__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SQCONN(s) (MYSQL *)s->conn
|
||||
|
||||
|
||||
struct stored_conn_t {
|
||||
int conn_id;
|
||||
char *name;
|
||||
size_t name_len;
|
||||
|
||||
void *conn;
|
||||
|
||||
int isOpen :1;
|
||||
int isTransact :1;
|
||||
int needsReset :1;
|
||||
int __FLAGS;
|
||||
uint8_t isOpen :1;
|
||||
uint8_t inTransaction :1;
|
||||
uint8_t needsReset :1;
|
||||
|
||||
unsigned int timeout;
|
||||
|
||||
@@ -19,30 +23,25 @@ struct stored_conn_t {
|
||||
struct stored_conn_t *next;
|
||||
};
|
||||
|
||||
|
||||
// Connections are stored in a linked list, these functions provide access
|
||||
struct stored_conn_t *connectionById(int conn_id);
|
||||
struct stored_conn_t *connectionByName(const char *name);
|
||||
|
||||
int connectionCount();
|
||||
|
||||
// Connection management
|
||||
struct stored_conn_t *createStoredConnection(const char *name);
|
||||
struct stored_conn_t *resetStoredConnection(struct stored_conn_t *sconn);
|
||||
void destroyStoredConnection(struct stored_conn_t *sconn);
|
||||
void destroyAllConnections();
|
||||
|
||||
int connectionCount();
|
||||
|
||||
int setTimeout(struct stored_conn_t *sconn, unsigned int timeout);
|
||||
void setDefaultTimeout(unsigned int timeout);
|
||||
|
||||
|
||||
int connectToHost(struct stored_conn_t *sconn,
|
||||
int connectToHost(struct stored_conn_t *sconn,
|
||||
const char *host, unsigned int port,
|
||||
const char *user, const char *passwd, const char *db);
|
||||
int connectToSocket(struct stored_conn_t *sconn,
|
||||
const char *unix_socket,
|
||||
const char *user, const char *passwd, const char *db);
|
||||
|
||||
void closeConnection(struct stored_conn_t *sconn);
|
||||
void closeAllConnections();
|
||||
|
||||
#endif // __CONNECTION_H__
|
||||
#endif // H__DB_CONNECTION__
|
||||
|
||||
Reference in New Issue
Block a user