summaryrefslogtreecommitdiffstats
path: root/database/eurephiadb_mapping.h
diff options
context:
space:
mode:
Diffstat (limited to 'database/eurephiadb_mapping.h')
-rw-r--r--database/eurephiadb_mapping.h97
1 files changed, 87 insertions, 10 deletions
diff --git a/database/eurephiadb_mapping.h b/database/eurephiadb_mapping.h
index 954b953..932006e 100644
--- a/database/eurephiadb_mapping.h
+++ b/database/eurephiadb_mapping.h
@@ -22,25 +22,62 @@
*
*/
+/**
+ * @file eurephiadb_mapping.h
+ * @author David Sommerseth <dazo@users.sourceforge.net>
+ * @date 2008-12-06
+ *
+ * @brief Database field mapping between database and the C code/programs
+ *
+ * This feature makes it possible to let each database driver implementation to
+ * use its own table and column/field names in the database, while having a
+ * unified interface for table names and field names in the application.
+ *
+ * @remark The database may not have all assigned fields in the table as indicated here,
+ * as this is a way how to get around queries which uses JOIN between more tables.
+ */
+
#ifndef EUREPHIADB_MAPPING_H
# define EUREPHIADB_MAPPING_H
+/**
+ * Enumeration of different field types
+ */
typedef enum eDBfieldType_e { ft_UNDEF, ft_INT, ft_STRING, ft_DATETIME, ft_PASSWD, ft_SETNULL } eDBfieldType;
+
+/**
+ * Enumeration of different SQL filter types (IS NULL, =, !=, <=, >=, >, <, etc)
+ */
typedef enum eDBfieldFilterType_e { flt_NOTSET, flt_EQ, flt_NEQ, flt_LT, flt_LTE, flt_GT, flt_GTE } eDBfieldFilterType;
+/**
+ * Definition of the eDBfieldMap structure which maps a given numeric table ID and field ID
+ * to a specific field name. This structure can also holds values for these fields to be used
+ * when doing SELECT, UPDATE or DELETE queries with WHERE sections and new values when doing
+ * INSERT INTO and UPDATE
+ */
typedef struct _eDBfieldMap_s {
- int tableid;
- char *table_alias;
- long field_id;
- eDBfieldType field_type;
- eDBfieldFilterType filter_type;
- char *field_name;
- char *value;
- struct _eDBfieldMap_s *next;
+ int tableid; /**< @see TABLE_USERS */
+ char *table_alias; /**< If the table needs an alias in the SQL query,
+ it should be set here*/
+ long field_id; /**< @see FIELD_NONE */
+ eDBfieldType field_type; /**< Defines what kind of data this field stores */
+ eDBfieldFilterType filter_type; /**< Only for WHERE sections, defines what kind of filter
+ mode to use */
+ char *field_name; /**< Name of the field as a string */
+ char *value; /**< Value of the field */
+ struct _eDBfieldMap_s *next; /**< Creates a pointer chain */
} eDBfieldMap;
extern const char *SESSION_STATUS[];
+/**
+ * TABLE ID definitions
+ *
+ * Gives each table needed for eurephia a numeric ID. These IDs are sequential numbers, starting on 1
+ * and being increased by 1.
+ * @{
+ */
#define TABLE_USERS 0x01
#define TABLE_CERTS 0x02
#define TABLE_USERCERTS 0x03
@@ -49,9 +86,19 @@ extern const char *SESSION_STATUS[];
#define TABLE_BLACKLIST 0x06
#define TABLE_EUREPHIAADMACC 0x07
#define TABLE_FWPROFILES 0x08
+/**
+ * @}
+ */
-#define FIELD_NONE 0x0000000
-#define FIELD_RECID 0x0000001 // Primary keys
+/**
+ * FIELD ID definitions
+ *
+ * Gives each table needed for eurephia a numeric ID. These IDs are increased by 2^x as these
+ * fields can be processed in a bit-wise manner by some functions.
+ * @{
+ */
+#define FIELD_NONE 0x0000000 /**< Special field */
+#define FIELD_RECID 0x0000001 /**< Special field, should be used to indicate primary key of the table */
#define FIELD_UID 0x0000002
#define FIELD_CERTID 0x0000004
#define FIELD_UNAME 0x0000008
@@ -86,10 +133,16 @@ extern const char *SESSION_STATUS[];
#define FIELD_DESCR 0x4000000
#define FIELD_FWPROFILE 0x8000000
+/**
+ * @}
+ */
#ifdef EUREPHIADB_MAPPING_C
+/**
+ * Unified eurephia field names for the 'users' table
+ */
static eDBfieldMap eTblMap_user[] = {
{TABLE_USERS, NULL, FIELD_RECID, ft_INT, flt_EQ, "uid", NULL, NULL},
{TABLE_USERS, NULL, FIELD_UNAME, ft_STRING, flt_EQ, "username", NULL, NULL},
@@ -100,6 +153,9 @@ static eDBfieldMap eTblMap_user[] = {
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+/**
+ * Unified eurephia field names for the 'certificates' table
+ */
static eDBfieldMap eTblMap_certificates[] = {
{TABLE_CERTS, NULL, FIELD_RECID, ft_INT, flt_EQ, "certid", NULL, NULL},
{TABLE_CERTS, NULL, FIELD_CERTDEPTH, ft_INT, flt_EQ, "depth", NULL, NULL},
@@ -111,6 +167,9 @@ static eDBfieldMap eTblMap_certificates[] = {
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+/**
+ * Unified eurephia field names for the 'lastlog' table
+ */
static eDBfieldMap eTblMap_lastlog[] = {
{TABLE_LASTLOG, NULL, FIELD_UID, ft_INT, flt_EQ, "uid", NULL, NULL},
{TABLE_LASTLOG, NULL, FIELD_CERTID, ft_INT, flt_EQ, "certid", NULL, NULL},
@@ -126,6 +185,9 @@ static eDBfieldMap eTblMap_lastlog[] = {
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+/**
+ * Unified eurephia field names for the 'attempts log' table
+ */
static eDBfieldMap eTblMap_attempts[] = {
{TABLE_ATTEMPTS, NULL, FIELD_UNAME, ft_STRING, flt_EQ, "username", NULL, NULL},
{TABLE_ATTEMPTS, NULL, FIELD_REMOTEIP, ft_STRING, flt_EQ, "ip", NULL, NULL},
@@ -137,6 +199,10 @@ static eDBfieldMap eTblMap_attempts[] = {
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+
+/**
+ * Unified eurephia field names for the 'blacklist' table
+ */
static eDBfieldMap eTblMap_blacklist[] = {
{TABLE_BLACKLIST, NULL, FIELD_UNAME, ft_STRING, flt_EQ, "username", NULL, NULL},
{TABLE_BLACKLIST, NULL, FIELD_REMOTEIP, ft_STRING, flt_EQ, "ip", NULL, NULL},
@@ -147,6 +213,10 @@ static eDBfieldMap eTblMap_blacklist[] = {
{0, NULL, 0, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+
+/**
+ * Unified eurephia field names for the 'usercerts' table
+ */
static eDBfieldMap eTblMap_usercerts[] = {
{TABLE_USERCERTS, NULL, FIELD_UID, ft_INT, flt_EQ, "uid", NULL, NULL},
{TABLE_USERCERTS, NULL, FIELD_CERTID, ft_INT, flt_EQ, "certid", NULL, NULL},
@@ -156,6 +226,10 @@ static eDBfieldMap eTblMap_usercerts[] = {
{0, NULL, FIELD_NONE, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+
+/**
+ * Unified eurephia field names for the 'eurephia_adminaccess' table
+ */
static eDBfieldMap eTblMap_eurephiaadmacc[] = {
{TABLE_EUREPHIAADMACC, NULL, FIELD_UID, ft_INT, flt_EQ, "uid", NULL, NULL},
{TABLE_EUREPHIAADMACC, NULL, FIELD_INTERFACE, ft_STRING, flt_EQ, "interface", NULL, NULL},
@@ -163,6 +237,9 @@ static eDBfieldMap eTblMap_eurephiaadmacc[] = {
{0, NULL, FIELD_NONE, ft_UNDEF, flt_NOTSET, NULL, NULL, NULL}
};
+/**
+ * Unified eurephia field names for the 'accessprofiles' table
+ */
static eDBfieldMap eTblMap_fwprofiles[] = {
{TABLE_FWPROFILES, NULL, FIELD_DESCR, ft_STRING , flt_EQ, "description", NULL, NULL},
{TABLE_FWPROFILES, NULL, FIELD_FWPROFILE, ft_STRING , flt_EQ, "fwprofile", NULL, NULL},