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) |
| eDBfieldMap * | eDBgetTableFieldMapping (int table) |
| void | eDBcopyMapAttribs (eDBfieldMap *newmap, eDBfieldMap *dbmap, int field) |
| eDBfieldMap * | eDBxmlMapping (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 [] |
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.
Definition in file eurephiadb_mapping.c.
| void eDBcopyMapAttribs | ( | eDBfieldMap * | newmap, | |
| eDBfieldMap * | dbmap, | |||
| int | field | |||
| ) | [inline] |
Internal function for copying over a particular field from one eDBfieldMap to another one
| 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
| 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_
| table | table index (integer) |
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.
| map | eDBfieldMap containing the database specific mapping and field values set |
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.
| map | eDBfieldMap with the values | |
| field_id | The field ID to retrieve the value from |
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.
| tfmap | eDBfieldMap specific to the database driver. | |
| skeys_str | Comma separated string containing the field names for the ORDER BY clause |
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.
| 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. |
< 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
| n | xmlNode to extract the value from. |
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
| attr | xmlAttr pointer from an xmlNode pointer. | |
| key | The attribute name to search for |
Definition at line 74 of file eurephia_xml.c.
Here is the caller graph for this function:| const char* SESSION_STATUS[] |
{
"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[] |
{
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.
1.7.1