summaryrefslogtreecommitdiffstats
path: root/database/eurephiadb_mapping.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/eurephiadb_mapping.c')
-rw-r--r--database/eurephiadb_mapping.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/database/eurephiadb_mapping.c b/database/eurephiadb_mapping.c
index 52c2909..311dbd4 100644
--- a/database/eurephiadb_mapping.c
+++ b/database/eurephiadb_mapping.c
@@ -423,15 +423,15 @@ long int eDBmappingFieldsPresent(eDBfieldMap *map) {
/**
- * Retrieves the value of a field in a eDBfieldMap pointer chain.
+ * Looks up a given fieldMap entry to a given field
*
* @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.
+ * @returns the pointer to the fieldMap entry on success, otherwise NULL
*/
-const char *eDBmappingGetValue(eDBfieldMap *map, long field_id) {
+static eDBfieldMap *_eDBmappingGetFieldMapEntry(eDBfieldMap *map, long long field_id)
+{
eDBfieldMap *ptr = NULL;
if( map == NULL ) {
@@ -440,9 +440,42 @@ const char *eDBmappingGetValue(eDBfieldMap *map, long field_id) {
for( ptr = map; ptr != NULL; ptr = ptr->next ) {
if( ptr->field_id == field_id ) {
- return ptr->value;
+ return ptr;
}
}
return NULL;
}
+/**
+ * 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 long field_id) {
+ eDBfieldMap *ptr = _eDBmappingGetFieldMapEntry(map, field_id);
+ return (ptr != NULL ? ptr->value : NULL);
+}
+
+
+/**
+ * Sets the value of a field in a eDBfieldMap pointer chain.
+ *
+ * @param map eDBfieldMap with the values
+ * @param field_id The field ID to modify
+ * @param value String pointer to the value to use
+ *
+ * @return Returns 1 on success, otherwise 0
+ */
+int eDBmappingSetValue(eDBfieldMap *map, long long field_id, char *value) {
+ eDBfieldMap *ptr = _eDBmappingGetFieldMapEntry(map, field_id);
+ if( ptr != NULL ) {
+ ptr->value = strdup_nullsafe(value);
+ return 1;
+ }
+ return 0;
+}
+