Changeset - 16f1b9b211d7
[Not reviewed]
default
0 2 0
LordOfWar - 16 years ago 2009-11-11 03:05:19

started the user manager, a lot of stuff to go...
2 files changed with 52 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/user_mgr.c
Show inline comments
 
@@ -18,3 +18,49 @@
 
*/
 

	
 
#include "user_mgr.h"
 
#include "malloc.h"
 

	
 
struct user_mgr_info
 
{
 
	struct user *user_array;
 
	int current_users;
 
} user_mgr_info;
 

	
 
int resize_user_array()
 
{
 
	int counter;
 
	int counter2;
 

	
 
	// create array twice the size of the current amount of users
 
	struct user *new_user_array = malloc(sizeof(struct user) * user_mgr_info.current_users * 2);
 

	
 
	// this copies the original user_array over to the new one
 
	// using two counters allows the array to be resized at any time
 
	// leaving exactly 1 open space between each user when it is done;
 
	counter2 = 0;
 
	for(counter = 0; counter < user_mgr_info.current_users; counter++)
 
	{
 
		if(user_mgr_info.user_array[counter].username != 0)
 
		{
 
			new_user_array[counter2*2] = user_mgr_info.user_array[counter];
 
			counter2++;
 
		}
 
	}
 

	
 
	// cleanup old array
 
	free(user_mgr_info.user_array);
 

	
 
	// change the pointer to point to the new user array
 
	user_mgr_info.user_array = new_user_array;
 

	
 
	return 1;
 
}
 

	
 
int initialize_users()
 
{
 
	// pull data from XML file
 

	
 
	// if XML file is not found create new array of size 50
 

	
 
	return 1;
 
}
src/server/user_mgr.h
Show inline comments
 
@@ -25,6 +25,11 @@
 
#ifndef _DISTREN_USER_MGR_H
 
#define _DISTREN_USER_MGR_H
 

	
 

	
 
struct user
 
{
 
	char *username;
 
	int render_power;
 
	int last_job;
 
};
 

	
 
#endif
0 comments (0 inline, 0 general)