#include "rest_proxy_stat.h"
#include "rest_proxy.h"


/* -------------------------------------*/
void rest_proxy_stat_count(int stat_type)
{
	static int *state_count[STAT_MAX];
	static char b_loaded = 0;
	if(b_loaded == 0)
	{
		state_count[STAT_QUERY_REQ] = &g_rest_proxy_env.query_req_num;
		state_count[STAT_QUERY_RES] = &g_rest_proxy_env.query_res_num;
		state_count[STAT_QUERY_REST_SUBSID_REQ] = &g_rest_proxy_env.query_rest_subscrib_req_num;
		state_count[STAT_QUERY_REST_SUBSID_RES] = &g_rest_proxy_env.query_rest_subscrib_res_num;
		state_count[STAT_QUERY_REST_REQ] = &g_rest_proxy_env.query_rest_req_num;
		state_count[STAT_QUERY_REST_RES] = &g_rest_proxy_env.query_rest_res_num;

		state_count[STAT_TOPUP_REQ] = &g_rest_proxy_env.topup_req_num;
		state_count[STAT_TOPUP_RES] = &g_rest_proxy_env.topup_res_num;
		state_count[STAT_TOPUP_REST_SUBSID_REQ] = &g_rest_proxy_env.topup_rest_subscrib_req_num;
		state_count[STAT_TOPUP_REST_SUBSID_RES] = &g_rest_proxy_env.topup_rest_subscrib_res_num;
		state_count[STAT_TOPUP_REST_REQ] = &g_rest_proxy_env.topup_rest_req_num;
		state_count[STAT_TOPUP_REST_RES] = &g_rest_proxy_env.topup_rest_res_num;

		state_count[STAT_TRANSFER_REQ] = &g_rest_proxy_env.trans_req_num;
		state_count[STAT_TRANSFER_RES] = &g_rest_proxy_env.trans_res_num;
		state_count[STAT_TRANSFER_REST_SUBSID_REQ_SENDER] = &g_rest_proxy_env.trans_rest_subscrib_req_num_out;
		state_count[STAT_TRANSFER_REST_SUBSID_RES_SENDER] = &g_rest_proxy_env.trans_rest_subscrib_res_num_out;

		state_count[STAT_TRANSFER_REST_SUBSID_REQ_RECEIVER] = &g_rest_proxy_env.trans_rest_subscrib_req_num_in;
		state_count[STAT_TRANSFER_REST_SUBSID_RES_RECEIVER] = &g_rest_proxy_env.trans_rest_subscrib_res_num_in;
		state_count[STAT_TRANSFER_REST_REQ] = &g_rest_proxy_env.trans_rest_req_num;
		state_count[STAT_TRANSFER_REST_RES] = &g_rest_proxy_env.trans_rest_res_num;

	
		b_loaded = 1;
	}

	(*state_count[stat_type]) += 1;
	#if 0
	switch(stat_type)
	{
		case STAT_QUERY_REQ:
			g_rest_proxy_env.query_req_num++;
		break;
		case STAT_QUERY_RES:
			g_rest_proxy_env.query_res_num++;
		break;
		case STAT_QUERY_REST_SUBSID_REQ:
			g_rest_proxy_env.query_rest_subscrib_req_num++;
		break;
		case STAT_QUERY_REST_SUBSID_RES:
			g_rest_proxy_env.query_rest_subscrib_res_num++;
		break; 
		case STAT_QUERY_REST_REQ:
			g_rest_proxy_env.query_rest_req_num++;
		break;
		case STAT_QUERY_REST_RES:
			g_rest_proxy_env.query_rest_res_num++;
		break;
		case STAT_TOPUP_REQ:
			g_rest_proxy_env.topup_req_num++;
		break;
		case STAT_TOPUP_RES:
			g_rest_proxy_env.topup_res_num++;
		break;
		case STAT_TOPUP_REST_SUBSID_REQ:
			g_rest_proxy_env.topup_rest_subscrib_req_num++;
		break;
		case STAT_TOPUP_REST_SUBSID_RES:
			g_rest_proxy_env.topup_rest_subscrib_res_num++;
		break;
		case STAT_TOPUP_REST_REQ:
			g_rest_proxy_env.topup_rest_req_num++;
		break;
		case STAT_TOPUP_REST_RES:
			g_rest_proxy_env.topup_rest_res_num++;
		break;
	}
	#endif
}

