summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-21 00:16:25 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-21 00:16:25 +0200
commitc3b6b7fb50259997bccb116eb4d6c6e290326eae (patch)
treed8fa7a8f1af73449ecba015507eafb33de894336
parent3c3584aba09bebe1300ce846d586d71d84beba33 (diff)
downloadeurephia-c3b6b7fb50259997bccb116eb4d6c6e290326eae.tar.gz
eurephia-c3b6b7fb50259997bccb116eb4d6c6e290326eae.tar.xz
eurephia-c3b6b7fb50259997bccb116eb4d6c6e290326eae.zip
Added eDBmappingGetValue() to retrieve field values from a eDBfieldMap struct
-rw-r--r--database/eurephiadb_mapping.c26
-rw-r--r--database/eurephiadb_mapping.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/database/eurephiadb_mapping.c b/database/eurephiadb_mapping.c
index 2541c4c..3a2513a 100644
--- a/database/eurephiadb_mapping.c
+++ b/database/eurephiadb_mapping.c
@@ -417,3 +417,29 @@ long int eDBmappingFieldsPresent(eDBfieldMap *map) {
}
return ret;
}
+
+
+/**
+ * Retrieves the value of a field in a eDBfieldMap pointer chain.
+ *
+ * @param map eDBfieldMap with the values
+ * @param field_id The field ID to retrieve the value from
+ *
+ * @return 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.
+ */
+const char *eDBmappingGetValue(eDBfieldMap *map, long field_id) {
+ eDBfieldMap *ptr = NULL;
+
+ if( map == NULL ) {
+ return NULL;
+ }
+
+ for( ptr = map; ptr != NULL; ptr = ptr->next ) {
+ if( ptr->field_id == field_id ) {
+ return ptr->value;
+ }
+ }
+ return NULL;
+}
+
diff --git a/database/eurephiadb_mapping.h b/database/eurephiadb_mapping.h
index 932006e..262231e 100644
--- a/database/eurephiadb_mapping.h
+++ b/database/eurephiadb_mapping.h
@@ -264,6 +264,7 @@ void eDBfreeMapping(eDBfieldMap *p);
eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tblalias, xmlNode *fmap_n);
char *eDBmkSortKeyString(eDBfieldMap *tfmap, const char *skeys_str);
long int eDBmappingFieldsPresent(eDBfieldMap *map);
+const char *eDBmappingGetValue(eDBfieldMap *map, long field_id);
#endif // HAVE_LIBXML2
#endif // !EUREPHIADB_MAPPING_H