appkey.cpp

来自「linux 上http email 协议分析程序 主要能够处理大数据量的主干网」· C++ 代码 · 共 84 行

CPP
84
字号
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Consts.h"
#include "Utility.h"
#include "AppKey.h"
#include "Stru.h"
#include "Db.h"

CAppKey::CAppKey()
{
	
	CTblPARA tblpara;
	STRU_TR_T_GENERALPARA rec;
	char *buf;
	buf=new char[1024*1024];
	memset(buf,0,sizeof(buf));

	while(tblpara.fetchRecord(&rec,"EMAILKEY")==0)
	{
		TU::delSpace(rec.GPR_PARAVALUE);
		strcat(buf,rec.GPR_PARAVALUE);
	}

	m_itotemailkey=0;
	if(strlen(buf)==0)
	{
		return;
	}
	
	char *p=strchr(buf,SEPARATOR_KEY);
	while(p!=NULL)
	{
		m_itotemailkey++;
		p=strchr(p+1,SEPARATOR_KEY);
	}

	m_pemailkey=new char[m_itotemailkey*(128+1)];
	memset(m_pemailkey,0,m_itotemailkey*(128+1));

	char *plast=buf;
	int len;
	int ikey=0;
	p=strchr(buf,SEPARATOR_KEY);
	while(p!=NULL)
	{
		len=p-plast;
		if(len<=128)
		{
			memcpy(m_pemailkey+(ikey*(128+1)),plast,len);

		}
		plast=p+1;
		p=strchr(plast,SEPARATOR_KEY);
		ikey++;
	}

	for(int i=0;i<m_itotemailkey;i++)
	{
		printf("email-key=[%s]\n",m_pemailkey+i*(128+1));
	}
	delete buf;

}

CAppKey::~CAppKey()
{
	if(m_pemailkey!=NULL)
		delete m_pemailkey;
}


char * CAppKey::searchKey(char *pszcontent,int lencontent)
{
	char *ptr;
	for(int i=0;i< m_itotemailkey;i++)
	{
		 ptr=TU::searchKey(pszcontent, lencontent,m_pemailkey+i*(128+1) );
		 if(ptr!=NULL)
			 return ptr;
	}
	return NULL;

}

⌨️ 快捷键说明

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