int decrement_client_count()

in tacacs-F4.0.4.28/client_count.c [111:134]


int decrement_client_count(char* client_ip) {
  CLIENT *nc;
  int count = get_client_count(client_ip);
  if (! count) {
    return 0;
  }
  count--;
  if (count >= 1) {
    /* we update the existing hash entry if the count is still positive
     * but the hash does not support update so we have to delete
     * and then add */
    CLIENT *nc = (CLIENT *)tac_malloc(sizeof(CLIENT));
    memset(nc, 0, sizeof(CLIENT));
    nc->name = tac_strdup(client_ip);
    nc->hash = NULL;
    nc->con_count = count;
    remove_client_entry(client_ip);
    hash_add_entry(client_table, (void *)nc);
  } else if (count == 0) {
    /* if it was the last client, we delete the entry */
    remove_client_entry(client_ip);
  }
  return count;
}