int ht_insert_host_agent (TCBDB * bdb, int data_nkey, int agent_nkey) { TCLIST *list; int in_list = 0; if (bdb == NULL) return (EINVAL); if ((list = tcbdbget4 (bdb, &data_nkey, sizeof (int))) != NULL) { if (is_value_in_tclist (list, &agent_nkey)) in_list = 1; tclistdel (list); } if (!in_list && tcbdbputdup (bdb, &data_nkey, sizeof (int), &agent_nkey, sizeof (int))) return 0; return 1; }
/* Insert a string key and the corresponding string value. * Note: If the key exists, the value is not replaced. * * On error, or if found, 1 is returned. * On success, or if not in the list, 0 is returned. */ int ins_igsl (void *hash, int key, int value) { TCLIST *list; int in_list = 0; if (!hash) return -1; /* key found, check if key exists within the list */ if ((list = tcbdbget4 (hash, &key, sizeof (int))) != NULL) { if (is_value_in_tclist (list, &value)) in_list = 1; tclistdel (list); } /* if not on the list, add it */ if (!in_list && tcbdbputdup (hash, &key, sizeof (int), &value, sizeof (int))) return 0; return -1; }