diff --git a/src/core/store.c b/src/core/store.c
index b9335818c203a753cd3fa84ae2db18b270e7cfe7..e8a693ce0c268b228bab54e29614a49447517e6e 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
const sdb_attribute_t *attr = (const sdb_attribute_t *)obj;
sdb_attribute_t *new;
const sdb_attribute_t *attr = (const sdb_attribute_t *)obj;
sdb_attribute_t *new;
- new = sdb_attribute_create(attr->hostname,
- obj->name, attr->attr_value);
+ new = SDB_ATTR(sdb_object_create(obj->name, sdb_attribute_type,
+ attr->hostname, attr->attr_value));
if (! new)
return NULL;
if (! new)
return NULL;
const sdb_service_t *svc = (const sdb_service_t *)obj;
sdb_service_t *new;
const sdb_service_t *svc = (const sdb_service_t *)obj;
sdb_service_t *new;
- new = sdb_service_create(svc->hostname, obj->name);
+ new = SDB_SVC(sdb_object_create(obj->name, sdb_service_type,
+ svc->hostname));
if (! new)
return NULL;
if (! new)
return NULL;
return host != NULL;
} /* sdb_store_has_host */
return host != NULL;
} /* sdb_store_has_host */
-sdb_attribute_t *
-sdb_attribute_create(const char *hostname,
- const char *name, const char *value)
-{
- sdb_object_t *obj;
-
- if ((! hostname) || (! name) || (! value))
- return NULL;
-
- obj = sdb_object_create(name, sdb_attribute_type, hostname, value);
- if (! obj)
- return NULL;
- return SDB_ATTR(obj);
-} /* sdb_attribute_create */
-
int
int
-sdb_store_attribute(const sdb_attribute_t *attr)
+sdb_store_attribute(const char *hostname, const char *key, const char *value,
+ sdb_time_t last_update)
{
sdb_host_t *host;
sdb_attribute_t *old;
{
sdb_host_t *host;
sdb_attribute_t *old;
- sdb_time_t last_update;
int status = 0;
int status = 0;
- if (! attr)
+ if ((! hostname) || (! key))
return -1;
return -1;
- last_update = attr->_last_update;
if (last_update <= 0)
last_update = sdb_gettime();
if (last_update <= 0)
last_update = sdb_gettime();
pthread_rwlock_wrlock(&host_lock);
pthread_rwlock_wrlock(&host_lock);
- host = SDB_HOST(sdb_llist_search_by_name(host_list, attr->hostname));
+ host = SDB_HOST(sdb_llist_search_by_name(host_list, hostname));
if (! host) {
pthread_rwlock_unlock(&host_lock);
return -1;
}
if (! host) {
pthread_rwlock_unlock(&host_lock);
return -1;
}
- old = SDB_ATTR(sdb_llist_search_by_name(host->attributes,
- SDB_CONST_OBJ(attr)->name));
+ old = SDB_ATTR(sdb_llist_search_by_name(host->attributes, key));
if (old) {
if (old->_last_update > last_update) {
sdb_log(SDB_LOG_DEBUG, "store: Cannot update attribute "
"'%s/%s' - value too old (%"PRIscTIME" < %"PRIscTIME")",
if (old) {
if (old->_last_update > last_update) {
sdb_log(SDB_LOG_DEBUG, "store: Cannot update attribute "
"'%s/%s' - value too old (%"PRIscTIME" < %"PRIscTIME")",
- attr->hostname, SDB_CONST_OBJ(attr)->name, last_update,
- old->_last_update);
+ hostname, key, last_update, old->_last_update);
status = 1;
}
else {
status = 1;
}
else {
}
}
else {
}
}
else {
- sdb_attribute_t *new = SDB_ATTR(sdb_object_clone(SDB_CONST_OBJ(attr)));
+ sdb_attribute_t *new = SDB_ATTR(sdb_object_create(key,
+ sdb_attribute_type, hostname, value));
if (! new) {
char errbuf[1024];
sdb_log(SDB_LOG_ERR, "store: Failed to clone attribute "
if (! new) {
char errbuf[1024];
sdb_log(SDB_LOG_ERR, "store: Failed to clone attribute "
return status;
} /* sdb_store_attribute */
return status;
} /* sdb_store_attribute */
-sdb_service_t *
-sdb_service_create(const char *hostname, const char *name)
-{
- sdb_object_t *obj;
-
- if ((! hostname) || (! name))
- return NULL;
-
- obj = sdb_object_create(name, sdb_service_type, hostname);
- if (! obj)
- return NULL;
- return SDB_SVC(obj);
-} /* sdb_service_create */
-
int
sdb_store_service(const sdb_service_t *svc)
{
int
sdb_store_service(const sdb_service_t *svc)
{
return status;
} /* sdb_store_service */
return status;
} /* sdb_store_service */
-const sdb_service_t *
-sdb_store_get_service(const sdb_host_t *host, const char *name)
-{
- sdb_service_t *svc;
-
- if ((! host) || (! name))
- return NULL;
-
- svc = SDB_SVC(sdb_llist_search_by_name(host->services, name));
- if (! svc)
- return NULL;
- return svc;
-} /* sdb_store_get_service */
-
int
sdb_store_dump(FILE *fh)
{
int
sdb_store_dump(FILE *fh)
{