Mercurial > hg > nnchat
diff libnnchat.c @ 102:b096ae97fc7d
Renamed functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 11 Oct 2010 15:48:05 +0300 |
parents | 218efd2f0641 |
children | eaa524e153f9 |
line wrap: on
line diff
--- a/libnnchat.c Mon Oct 11 15:47:48 2010 +0300 +++ b/libnnchat.c Mon Oct 11 15:48:05 2010 +0300 @@ -1,7 +1,7 @@ /* * NNChat - Custom chat client for NewbieNudes.com chatrooms * Written by Matti 'ccr' Hämäläinen - * (C) Copyright 2008 Tecnic Software productions (TNSP) + * (C) Copyright 2008-2010 Tecnic Software productions (TNSP) */ #include "libnnchat.h" @@ -562,10 +562,10 @@ } -static uint8_t hashUserName(char *name) +static uint8_t nn_hash_user(const char *name) { int n = 0; - uint8_t *c = (uint8_t *)name; + const uint8_t *c = (uint8_t *)name; uint8_t hash = 0xff; while (*c && n < 4) { @@ -577,20 +577,20 @@ } -static void insertUser(nn_user_t **list, nn_user_t *node) +static void nn_user_insert(nn_user_t **list, nn_user_t *node) { node->next = *list; *list = node; } -nn_user_t *findUserEnc(nn_userhash_t *list, char *encname) +nn_user_t *nn_user_find_enc(const nn_userhash_t *list, const char *encname) { uint8_t hash; if (list == NULL) return NULL; - hash = hashUserName(encname); + hash = nn_hash_user(encname); if (list->buckets[hash] != NULL) { nn_user_t *curr = list->buckets[hash]; while (curr != NULL) { @@ -604,7 +604,7 @@ } -int addUserToHash(nn_userhash_t **list, char *encname) +int nn_user_add_to_hash(nn_userhash_t **list, const char *encname) { uint8_t hash; nn_user_t *user; @@ -621,7 +621,7 @@ } /* Check if username is already there */ - if (findUserEnc(*list, encname) != NULL) + if (nn_user_find_enc(*list, encname) != NULL) return 1; /* No, we'll add it */ @@ -633,13 +633,13 @@ if (user->encname == NULL || user->name == NULL) return -4; - hash = hashUserName(encname); - insertUser(&((*list)->buckets[hash]), user); + hash = nn_hash_user(encname); + nn_user_insert(&((*list)->buckets[hash]), user); return 0; } -nn_user_t *copyUser(nn_user_t *src) +nn_user_t *nn_user_copy(const nn_user_t *src) { nn_user_t *user; @@ -658,7 +658,7 @@ } -static void freeUser(nn_user_t *user) +static void nn_user_free(nn_user_t *user) { th_free(user->encname); th_free(user->name); @@ -666,27 +666,26 @@ } -void freeUserList(nn_user_t *list) +void nn_user_free_list(nn_user_t *list) { nn_user_t *next, *curr = list; while (curr != NULL) { next = curr->next; - freeUser(curr); + nn_user_free(curr); curr = next; } } -void freeUserHash(nn_userhash_t *hash) +void nn_user_free_hash(nn_userhash_t *hash) { int i; if (hash == NULL) return; for (i = 0; i < NN_NUM_BUCKETS; i++) { - freeUserList(hash->buckets[i]); + nn_user_free_list(hash->buckets[i]); hash->buckets[i] = NULL; } th_free(hash); } -