#ifndef _COMMON_H
#define _COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#define _LINUX
#include "vng.h"
#include "vng_p.h"

#ifdef __IQUE__
#define THREADS_PER_PROCESS 20
#define VN_NUM_PER_PROCESS 10
#else
#define THREADS_PER_PROCESS 1
#define VN_NUM_PER_PROCESS 1
#endif

#define MEM_MAX_NUM  20
#define CORRECT_NUM_MEM_INTERVAL (1*60)
#define UPDATE_STATUS_INTERVAL (1*10)

#define SHM_KEY 123

#ifdef __IQUE__
#define SERVER "vng.idc-beta.ique.com"
#else
#define SERVER "ogs.lab1.routefree.com"
#endif
#define PORT 16978

#define LOBBYENV "lobbypath"


#define MAX_PROCESS_NUM 100
typedef struct _RoomInfo
{
	VNId vid[MAX_PROCESS_NUM][VN_NUM_PER_PROCESS];
	unsigned int cur_mem_num[MAX_PROCESS_NUM][VN_NUM_PER_PROCESS];
}RoomsInfo;

typedef struct _Shared_st
{
	RoomsInfo rooms_info;
	int shut_down_server_flag;	
	int command;
}Shared_st;

enum 
{
	SHOW_NUM_MEMBERS=1,
}command;


#define DEBUG
//#define D_ERROR

#ifdef DEBUG
	#define PRINTF(...)  printf(__VA_ARGS__)
#else
	#define PRINTF(...)
#endif

#ifdef D_ERROR
	#define ERROR(...)  printf(__VA_ARGS__)
#else
	#define ERROR(...)
#endif

#define idHi(d)	((uint32_t)(((uint64_t)d & (((uint64_t) 0xffffffffLL) << 32)) >> 32))
#define idLo(d)	((uint32_t)(d & 0xffffffffLL))

#endif /* _COMMON_H */
