1 Star 0 Fork 5

大王叫我来巡山/call_demo_server

forked from 张远浩/call_demo_server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util.h 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef __UTIL_H__
#define __UTIL_H__
#define _CRT_SECURE_NO_DEPRECATE // remove warning C4996,
#include "ostype.h"
#include "UtilPdu.h"
#include "Lock.h"
#include "Log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _WIN32
#include <strings.h>
#endif
#include <sys/stat.h>
#include <assert.h>
#ifdef _WIN32
#define snprintf sprintf_s
#else
#include <stdarg.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#endif
#define NOTUSED_ARG(v) ((void)v) // used this to remove warning C4100, unreferenced parameter
/// yunfan modify end
class CRefObject
{
public:
CRefObject();
virtual ~CRefObject();
void SetLock(CLock* lock) { m_lock = lock; }
void AddRef();
void ReleaseRef();
private:
int m_refCount;
CLock* m_lock;
};
// Add By ZhangYuanhao 2015-01-14 For log show the file name not the full path + filename
#define __FILENAME__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1):__FILE__)
//#if defined(_WIN32) || defined(_WIN64)
//#define log(fmt, ...) EasyLog::Inst()->Log(mformat("<%s>\t<%d>\t<%s>,"fmt, __FILENAME__, __LINE__, __FUNCTION__, ##__VA_ARGS__))
//#else
#define log(fmt, args...) sysLog("<%s>|<%d>|<%s>," fmt, __FILENAME__, __LINE__, __FUNCTION__, ##args)
//#endif
//#define log(fmt, ...) printf("<%s>\t<%d>\t<%s>,\n" fmt, __FILENAME__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
uint64_t get_tick_count();
void util_sleep(uint32_t millisecond);
class CStrExplode
{
public:
CStrExplode(char* str, char seperator);
virtual ~CStrExplode();
uint32_t GetItemCnt() { return m_item_cnt; }
char* GetItem(uint32_t idx) { return m_item_list[idx]; }
private:
uint32_t m_item_cnt;
char** m_item_list;
};
char* replaceStr(char* pSrc, char oldChar, char newChar);
string int2string(uint32_t user_id);
uint32_t string2int(const string& value);
void replace_mark(string& str, string& new_value, uint32_t& begin_pos);
void replace_mark(string& str, uint32_t new_value, uint32_t& begin_pos);
void writePid();
inline unsigned char toHex(const unsigned char &x);
inline unsigned char fromHex(const unsigned char &x);
string URLEncode(const string &sIn);
string URLDecode(const string &sIn);
int64_t get_file_size(const char *path);
const char* memfind(const char *src_str,size_t src_len, const char *sub_str, size_t sub_len, bool flag = true);
void init_log();
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xxd/call_demo_server.git
git@gitee.com:xxd/call_demo_server.git
xxd
call_demo_server
call_demo_server
master

搜索帮助