Files @ 16f1b9b211d7
Branch filter:

Location: DistRen/src/server/user_mgr.c

LordOfWar
started the user manager, a lot of stuff to go...
/*
  Copyright 2009 Nathan Phillip Brink, Ethan Zonca, Matthew Orlando

  This file is a part of DistRen.

  DistRen is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  DistRen is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
*/

#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;
}