Code

store: Renamed sdb_store_get_host() to sdb_store_has_host().
[sysdb.git] / src / core / store.c
index 64e9f64064c50956b6afe56ed4dc35f5d9e5b72b..b9335818c203a753cd3fa84ae2db18b270e7cfe7 100644 (file)
@@ -84,7 +84,7 @@ sdb_host_do_clone(const sdb_object_t *obj)
        const sdb_host_t *host = (const sdb_host_t *)obj;
        sdb_host_t *new;
 
-       new = sdb_host_create(obj->name);
+       new = SDB_HOST(sdb_object_create(obj->name, sdb_host_type));
        if (! new)
                return NULL;
 
@@ -217,40 +217,24 @@ const sdb_type_t sdb_service_type = {
  * public API
  */
 
-sdb_host_t *
-sdb_host_create(const char *name)
-{
-       sdb_object_t *obj;
-
-       if (! name)
-               return NULL;
-
-       obj = sdb_object_create(name, sdb_host_type);
-       if (! obj)
-               return NULL;
-       return SDB_HOST(obj);
-} /* sdb_host_create */
-
 int
-sdb_store_host(const sdb_host_t *host)
+sdb_store_host(const char *name, sdb_time_t last_update)
 {
-       char *cname;
-
-       sdb_time_t last_update;
        sdb_host_t *old;
 
+       char *cname;
        int status = 0;
 
-       if ((! host) || (! SDB_CONST_OBJ(host)->name))
+       if (! name)
                return -1;
 
-       cname = sdb_plugin_cname(strdup(SDB_CONST_OBJ(host)->name));
+       cname = sdb_plugin_cname(strdup(name));
        if (! cname) {
                sdb_log(SDB_LOG_ERR, "store: strdup failed");
                return -1;
        }
 
-       last_update = host->_last_update;
+       last_update = last_update;
        if (last_update <= 0)
                last_update = sdb_gettime();
 
@@ -279,7 +263,7 @@ sdb_store_host(const sdb_host_t *host)
                }
        }
        else {
-               sdb_host_t *new = SDB_HOST(sdb_object_clone(SDB_CONST_OBJ(host)));
+               sdb_host_t *new = SDB_HOST(sdb_object_create(name, sdb_host_type));
                if (! new) {
                        char errbuf[1024];
                        sdb_log(SDB_LOG_ERR, "store: Failed to clone host object: %s",
@@ -326,8 +310,8 @@ sdb_store_host(const sdb_host_t *host)
        return status;
 } /* sdb_store_host */
 
-const sdb_host_t *
-sdb_store_get_host(const char *name)
+_Bool
+sdb_store_has_host(const char *name)
 {
        sdb_host_t *host;
 
@@ -335,10 +319,8 @@ sdb_store_get_host(const char *name)
                return NULL;
 
        host = SDB_HOST(sdb_llist_search_by_name(host_list, name));
-       if (! host)
-               return NULL;
-       return host;
-} /* sdb_store_get_host */
+       return host != NULL;
+} /* sdb_store_has_host */
 
 sdb_attribute_t *
 sdb_attribute_create(const char *hostname,