/*************************************************************************************************************
* This file contains loading of serverinfo
* 2012/8 by Dlxko
* Version 3.0
**************************************************************************************************************/
#include "ServerInfo.h"

// Function to create server info
void create_serverinfo()
{
	//Alloc buffers
	string info_tmp;
	char *info_tmp_char = new char[SERVER_INFO_SIZE];

	//Show startup info
	sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"#669900\"><b>Server settings</b></span>\n");
	info_tmp += warnings_tmp;

	if (PORT < SI_MAX_PORT)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Server port is:</b> %d\n", PORT);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Server port is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (server_socket < SI_MAX_SERVER_SOCK)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Server socket is:</b> %d\n", server_socket);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Server socket is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (MAX_CLIENTS < SI_MAX_CLIENTS)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Maximum clients is:</b> %d\n\n", MAX_CLIENTS);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Maximum clients is: Wrong value!</b></span>\n\n");
		info_tmp += warnings_tmp;
	}

	sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"#669900\"><b>Database settings</b></span>\n");
	info_tmp += warnings_tmp;

	if (strlen(DB_IP) < SI_MAX_DB_IP)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Database ip is:</b> %s\n", DB_IP);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Database ip is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (strlen(DB_USER) < SI_MAX_DB_USER)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Database user is:</b> %s\n", DB_USER);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Database user is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (strlen(DB_PASS) < SI_MAX_DB_PASS)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Database pass is:</b> %s\n", DB_PASS);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Database password is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (strlen(DB_NAME) < SI_MAX_DB_NAME)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Database name is:</b> %s\n", DB_NAME);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Database name is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (DB_PORT < SI_MAX_DB_PORT)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Database port is:</b> %d\n\n", DB_PORT);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Database port is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"#669900\"><b>Variables settings</b></span>\n");
	info_tmp += warnings_tmp;

	if (OPCODE_SIZE < SI_MAX_OPCODE_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Opcode size is:</b> %d\n", OPCODE_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Opcode size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (CODE_SIZE < SI_MAX_CODE_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Code size is:</b> %d\n", CODE_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Code size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (MSG_NUMB_SIZE < SI_MAX_MSG_NUM_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Message number size is:</b> %d\n", MSG_NUMB_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Message number size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (LENGHT_SIZE < SI_MAX_LENGHT_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Lenght size is:</b> %d\n", LENGHT_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Lenght size: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (DATA_ONE_SIZE < SI_MAX_FRIEND_DATA_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Friend data size is:</b> %d\n", DATA_ONE_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Friend data size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (PASS_SIZE < SI_MAX_PASS_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Pass size is:</b> %d\n", PASS_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Pass size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (EVENT_ID_SIZE < SI_MAX_EVENT_ID_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Event id size is:</b> %d\n", EVENT_ID_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Event id size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (AVATAR_SIZE < SI_MAX_AVATAR_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Avatar size is:</b> %d\n", AVATAR_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Avatar size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (FILE_NAME_SIZE < SI_MAX_FILE_NAME_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>File name size is:</b> %d\n", FILE_NAME_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>File name size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (WARNING_TMP_SIZE < SI_MAX_WARNING_TMP_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Warning size is:</b> %d\n", WARNING_TMP_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Warning size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (SERVER_INPUT_SIZE < SI_MAX_SERVER_INPUT_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Server input size is:</b> %d\n", SERVER_INPUT_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Server input size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (FILE_PATH_SIZE < SI_MAX_FILE_PATH_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>File path size is:</b> %d\n", FILE_PATH_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>File path size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (SERVER_INFO_SIZE < SI_MAX_SERVER_INFO_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Server info size is:</b> %d\n", SERVER_INFO_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Server info is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (BUFFER_SIZE < SI_MAX_BUFFER_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Buffer size is:</b> %d\n", BUFFER_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Buffer size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	if (MYSQL_TEXT_SIZE < SI_MAX_MYSQL_TEXT_SIZE)
	{
		memset(warnings_tmp, 0, WARNING_TMP_SIZE);
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<b>Mysql text size is:</b> %d\n", MYSQL_TEXT_SIZE);
		info_tmp += warnings_tmp;
	}
	else
	{
		sprintf_s(warnings_tmp, WARNING_TMP_SIZE, "<span foreground=\"red\"><b>Mysql text size is: Wrong value!</b></span>\n");
		info_tmp += warnings_tmp;
	}

	// Convert string to *char
	if (info_tmp.length() < SERVER_INFO_SIZE+1)
	{
		sprintf_s(info_tmp_char, SERVER_INFO_SIZE, "%s", info_tmp);
		gtk_label_set_markup (GTK_LABEL (server_definfo), info_tmp_char);
	}

	// Dealloc
	info_tmp.empty();
	delete info_tmp_char;
}