Defines | Functions | Variables

eurephiadb_mapping.c File Reference

Database field mapping between database and the C code/programs. More...

#include <string.h>
#include <assert.h>
#include <libxml/tree.h>
#include <eurephia_context.h>
#include <eurephia_log.h>
#include <eurephiadb_mapping.h>
#include <eurephia_nullsafe.h>
#include <passwd.h>
Include dependency graph for eurephiadb_mapping.c:

Go to the source code of this file.

Functions

char * xmlGetAttrValue (xmlAttr *properties, const char *key)
char * xmlExtractContent (xmlNode *n)
void eDBfreeMapping (eDBfieldMap *p)
eDBfieldMapeDBgetTableFieldMapping (int table)
void eDBcopyMapAttribs (eDBfieldMap *newmap, eDBfieldMap *dbmap, int field)
eDBfieldMapeDBxmlMapping (eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tblalias, xmlNode *fmapnode)
const char * eDBmkSortKeyString (eDBfieldMap *tfmap, const char *skeys_str)
long int eDBmappingFieldsPresent (eDBfieldMap *map)
const char * eDBmappingGetValue (eDBfieldMap *map, long field_id)

Variables

const char * TABLE_NAME []
const char * SESSION_STATUS []

Detailed Description

Database field mapping between database and the C code/programs.

Author:
David Sommerseth <dazo@users.sourceforge.net>
Date:
2008-12-06

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.

Definition in file eurephiadb_mapping.c.


Function Documentation

void eDBcopyMapAttribs ( eDBfieldMap newmap,
eDBfieldMap dbmap,
int  field 
) [inline]

Internal function for copying over a particular field from one eDBfieldMap to another one

Parameters:
newmap The destination map to be updated
dbmap The source map where to copy the data from
field The ID of the field which is being copied over

Definition at line 180 of file eurephiadb_mapping.c.

Here is the caller graph for this function:

void eDBfreeMapping ( eDBfieldMap p  ) 

Frees the memory used by a eDBfieldMap structure

Parameters:
p Pointer to the eDBfieldMap to be freed

Definition at line 88 of file eurephiadb_mapping.c.

Here is the call graph for this function:

Here is the caller graph for this function:

eDBfieldMap* eDBgetTableFieldMapping ( int  table  ) 

Internal function for mapping the unified eurephia mapping table from a table index. The table index is defined in eurephiadb_mapping.h, prefixed with TABLE_

Parameters:
table table index (integer)
Returns:
Returns a pointer to the corresponding eDBfieldMap if table index is found, otherwise NULL is returned.
See also:
eurephiadb_mapping.h

Definition at line 112 of file eurephiadb_mapping.c.

Here is the caller graph for this function:

long int eDBmappingFieldsPresent ( eDBfieldMap map  ) 

Tells which database fields in a eDBfieldMap are set and available.

Parameters:
map eDBfieldMap containing the database specific mapping and field values set
Returns:
Returns a bit-wise OR'ed value of all fields in an eDBfieldMap which have their values set to something else than NULL.

Definition at line 410 of file eurephiadb_mapping.c.

Here is the caller graph for this function:

const char* eDBmappingGetValue ( eDBfieldMap map,
long  field_id 
)

Retrieves the value of a field in a eDBfieldMap pointer chain.

Parameters:
map eDBfieldMap with the values
field_id The field ID to retrieve the value from
Returns:
Returns const char * to the value in the eDBfieldMap on success, or NULL if either the value is not found or if the value is not set.

Definition at line 434 of file eurephiadb_mapping.c.

Here is the caller graph for this function:

const char* eDBmkSortKeyString ( eDBfieldMap tfmap,
const char *  skeys_str 
)

Generates a database specific list which is comma separated for the database driver to use in the ORDER BY section of SQL queries. The unified database fields are being translated into the database specific field names.

Parameters:
tfmap eDBfieldMap specific to the database driver.
skeys_str Comma separated string containing the field names for the ORDER BY clause
Returns:
Returns a comma separated string with translated field names on success, otherwise NULL.
Remarks:
The resulting pointer is pointing at a static char pointer and should not be freed.

Definition at line 355 of file eurephiadb_mapping.c.

Here is the call graph for this function:

Here is the caller graph for this function:

eDBfieldMap* eDBxmlMapping ( eurephiaCTX ctx,
eDBfieldMap dbmap,
const char *  tblalias,
xmlNode *  fmapnode 
)

Create a eDBfieldMap to be used by the database driver, with the values from an fieldMapping XML node. This function will go through all fields in the XML tags, and associate the unified field names and table name with the database specific field/table names.

Parameters:
ctx eurephiaCTX
dbmap The database specific eDBfieldMap containing its own fields and table names
tblalias If the SQL needs to use an alias, this alias prefix will be used for the fields
fmapnode An xmlNode pointing at the fieldMapping node/tag.
Returns:
On success, a pointer to a eDBfieldMap specific for the database driver will be returned, otherwise NULL.

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

Definition at line 207 of file eurephiadb_mapping.c.

Here is the call graph for this function:

Here is the caller graph for this function:

char* xmlExtractContent ( xmlNode *  n  )  [inline]

Return the text content of a given xmlNode

Parameters:
n xmlNode to extract the value from.
Returns:
returns a char pointer with the text contents of an xmlNode.

Definition at line 334 of file eurephia_xml.c.

Here is the caller graph for this function:

char* xmlGetAttrValue ( xmlAttr *  attr,
const char *  key 
)

Retrieves a given XML node attribute/property

Parameters:
attr xmlAttr pointer from an xmlNode pointer.
key The attribute name to search for
Returns:
The value of the found attribute. If not found, NULL is returned.

Definition at line 74 of file eurephia_xml.c.

Here is the caller graph for this function:


Variable Documentation

const char* SESSION_STATUS[]
Initial value:
 {
        "UNKNOWN",
        "STARTED",
        "OPEN",
        "CLOSING",
        "CLOSED",
        "CLEANEDUP",
        NULL}

Simple mapping table for session status

Definition at line 66 of file eurephiadb_mapping.c.

const char* TABLE_NAME[]
Initial value:
 {
        NULL,
        "users",                 
        "certificates",          
        "usercerts",             
        "lastlog",               
        "attemptslog",           
        "blacklist",             
        "eurephia_adminaccess",  
        "firewall_profiles",     
        NULL}

Simple mapping table for table_id to string. Must match the order of the defined tables in eurephia_mapping.h

Definition at line 51 of file eurephiadb_mapping.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines