Reindent server/core/users.c

This commit is contained in:
Johan Wikman
2015-11-30 20:29:03 +02:00
parent 8bbc3e8086
commit fbecf128dd
2 changed files with 141 additions and 125 deletions

View File

@ -60,7 +60,11 @@ USERS *rval;
return NULL;
}
hashtable_memory_fns(rval->data, (HASHMEMORYFN)strdup, (HASHMEMORYFN)strdup, (HASHMEMORYFN)free, (HASHMEMORYFN)free);
hashtable_memory_fns(rval->data,
(HASHMEMORYFN)strdup,
(HASHMEMORYFN)strdup,
(HASHMEMORYFN)free,
(HASHMEMORYFN)free);
return rval;
}
@ -80,7 +84,9 @@ users_free(USERS *users)
}
if (users->data)
{
hashtable_free(users->data);
}
free(users);
}
@ -117,7 +123,8 @@ users_delete(USERS *users, char *user)
{
int del;
if (users->stats.n_entries == 1) {
if (users->stats.n_entries == 1)
{
return 0;
}
atomic_add(&users->stats.n_deletes, 1);
@ -153,7 +160,9 @@ int
users_update(USERS *users, char *user, char *auth)
{
if (hashtable_delete(users->data, user) == 0)
{
return 0;
}
return hashtable_add(users->data, user, auth);
}
@ -197,18 +206,22 @@ void *user;
dcb_printf(dcb, "User names: ");
sep = "";
if (users->usersCustomUserFormat != NULL) {
if (users->usersCustomUserFormat != NULL)
{
while ((user = hashtable_next(iter)) != NULL)
{
char *custom_user;
custom_user = users->usersCustomUserFormat(user);
if (custom_user) {
if (custom_user)
{
dcb_printf(dcb, "%s%s", sep, custom_user);
free(custom_user);
sep = ", ";
}
}
} else {
}
else
{
while ((user = hashtable_next(iter)) != NULL)
{
dcb_printf(dcb, "%s%s", sep, (char *)user);

View File

@ -42,7 +42,8 @@
/**
* The users table statistics structure
*/
typedef struct {
typedef struct
{
int n_entries; /**< The number of entries */
int n_adds; /**< The number of inserts */
int n_deletes; /**< The number of deletes */
@ -53,12 +54,12 @@ typedef struct {
* The user table, this contains the username and authentication data required
* for the authentication implementation within the gateway.
*/
typedef struct users {
typedef struct users
{
HASHTABLE *data; /**< The hashtable containing the actual data */
char *(*usersCustomUserFormat)(void *); /**< Optional username format routine */
USERS_STATS stats; /**< The statistics for the users table */
unsigned char
cksum[SHA_DIGEST_LENGTH]; /**< The users' table ckecksum */
unsigned char cksum[SHA_DIGEST_LENGTH]; /**< The users' table ckecksum */
} USERS;
extern USERS *users_alloc(); /**< Allocate a users table */
@ -66,7 +67,9 @@ extern void users_free(USERS *); /**< Free a users table */
extern int users_add(USERS *, char *, char *); /**< Add a user to the users table */
extern int users_delete(USERS *, char *); /**< Delete a user from the users table */
extern char *users_fetch(USERS *, char *); /**< Fetch the authentication data for a user */
extern int users_update(USERS *, char *, char *); /**< Change the password data for a user in the users table */
extern int users_update(USERS *, char *, char *); /**< Change the password data for a user in
the users table */
extern void usersPrint(USERS *); /**< Print data about the users loaded */
extern void dcb_usersPrint(DCB *, USERS *); /**< Print data about the users loaded */
#endif