-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
40 lines (27 loc) · 1.03 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __COMMON_H__
#define __COMMON_H__
#include <cstdio>
#include <string>
#include <vector>
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
#define DB_ADDR "localhost"
#define DB_HISTORY_NAME "ssq.history"
#define DB_RAND_NAME "ssq.rand"
#define LISTEN_IP "0.0.0.0"
#define LISTEN_PORT 6666
#define RAND_PER_COUNT 5
#define LOG_LV_ERR 0x01
#define LOG_LV_MSG 0x02
#define LOG_LV_DBG 0x04
u8 bit_count(u8 u);
u32 bit_count(u64 u);
char* nowTime();
void my_split(std::string& str,const char* delim, std::vector<std::string>& out);
extern int dbgOn;
#define LogDbg(fmt...){if(dbgOn & LOG_LV_DBG){printf("%s DBG %s:%d: ", nowTime(), __FILE__, __LINE__);printf(fmt);}}
#define LogMsg(fmt...){if(dbgOn & LOG_LV_MSG){printf("%s MSG %s:%d: ", nowTime(), __FILE__, __LINE__);printf(fmt);}}
#define LogErr(fmt...){if(dbgOn & LOG_LV_ERR){printf("%s ERR %s:%d: ", nowTime(), __FILE__, __LINE__);printf(fmt);}}
#endif //__COMMON_H__