util.h

来自「看到联通的接口协议的dll没」· C头文件 代码 · 共 83 行

H
83
字号
/**
*	util.h
*	Short Message Abstractive Library.(SMAL)
*/


#ifndef _SMAL_UTIL_H_
#define _SMAL_UTIL_H_

#include "smal.h"
#include "logqueue.h"
#include "const.h"

void ParseClientPara(CString szIcpid, CString szPwd, CString szSpid, CString szAddr);

///////////////////////////////////////////////////////////////////////////////
/*
 日志消息队列
*/
struct queues
{
	LOGQueue *m_logqueue;

	queues() {
		m_logqueue = NULL;
	}

	void Create() {
		m_logqueue = new LOGQueue(MAX_QUEUESIZE);
	}

	void Free()
	{
		if (NULL != m_logqueue)	
		{
			m_logqueue->shutdown();
			delete m_logqueue;
			m_logqueue = NULL;
		}
	}
};

/*
 线程信息结构体
*/
struct thread_info
{
	DWORD	m_pThreadId;
	HANDLE	m_hThread;
	bool	m_bBusyWorking;
	thread_info() 
	{
		m_hThread = 0; 
		m_bBusyWorking = false; 
	}
};


/*
    全局公共函数
	简单的截取字符串函数
	主要用于给结构体字符串成员赋值
*/
CString GetSubStr(
				  void* pchBuf,		// 要截取的字符串 
				  int nLen			// 从起始开始的截取长度
				  );

/** 
	获得日期时间函数
	格式"%04d-%02d-%02d %02d:%02d:%02d", 即YYYY-MM-DD hh:mm:ss:mss,主要用于记录日志的记录的时间戳
*/
CString GetDateTime();

/** 
	转换64位无符号整数的网络字节序
*/
#define hton64(i)   ( ((unsigned __int64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
#define ntoh64   hton64

int IsExpired();

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?