Reindent server/core/users.c
This commit is contained in:
@ -45,7 +45,7 @@
|
||||
USERS *
|
||||
users_alloc()
|
||||
{
|
||||
USERS *rval;
|
||||
USERS *rval;
|
||||
|
||||
if ((rval = calloc(1, sizeof(USERS))) == NULL)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
@ -73,14 +77,16 @@ USERS *rval;
|
||||
void
|
||||
users_free(USERS *users)
|
||||
{
|
||||
if(users == NULL)
|
||||
if (users == NULL)
|
||||
{
|
||||
MXS_ERROR("[%s:%d]: NULL parameter.", __FUNCTION__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
if(users->data)
|
||||
if (users->data)
|
||||
{
|
||||
hashtable_free(users->data);
|
||||
}
|
||||
free(users);
|
||||
}
|
||||
|
||||
@ -95,7 +101,7 @@ users_free(USERS *users)
|
||||
int
|
||||
users_add(USERS *users, char *user, char *auth)
|
||||
{
|
||||
int add;
|
||||
int add;
|
||||
|
||||
atomic_add(&users->stats.n_adds, 1);
|
||||
add = hashtable_add(users->data, user, auth);
|
||||
@ -115,9 +121,10 @@ int add;
|
||||
int
|
||||
users_delete(USERS *users, char *user)
|
||||
{
|
||||
int del;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -178,9 +187,9 @@ usersPrint(USERS *users)
|
||||
void
|
||||
dcb_usersPrint(DCB *dcb, USERS *users)
|
||||
{
|
||||
HASHITERATOR *iter;
|
||||
char *sep;
|
||||
void *user;
|
||||
HASHITERATOR *iter;
|
||||
char *sep;
|
||||
void *user;
|
||||
|
||||
dcb_printf(dcb, "Users table data\n");
|
||||
|
||||
@ -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);
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user