⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 revokecert.cpp

📁 cisoca_for_mysql 编码
💻 CPP
字号:
/* ====================================================================
 * The Ciso Software License, Version 1.0
 *
 * Copyright (c) 2003-2004 The Chinese Infomation security organization.  
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Ciso(Chinese Infomation Security Organization) Software 
 *        (http://www.infosecurity.org.cn/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 */
#include "stdafx.h"
#include "RevokeCert.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CRevokeCert, CObject,0)

CRevokeCert::CRevokeCert()
{

}
CRevokeCert::CRevokeCert(CString strSN,CString strTime)
{
	this->strSN		= strSN;
	this->strTime	= strTime;

}
CRevokeCert::~CRevokeCert()
{

}
long CRevokeCert::GetSNWithLong()
{
	return atol((char*)(LPCTSTR)strSN);	
}
char* CRevokeCert::GetTimeStr()
{
	return (char*)(LPCTSTR)strTime;
}

char* CRevokeCert::GetSNStr()
{
	return (char*)(LPCTSTR)strSN;
}

time_t CRevokeCert::GetTime()
{
	//Format "%04d-%02d-%02d %02d:%02d:%02d"
	struct tm stTIME;
	char buf[64]= {0};
	char tmp[10]= {0};
	char *p=buf;
	// 格式检查
	if(CheckTimeFormat((char*)(LPCTSTR)strTime)!=1)
		return -1L;
	strcpy(buf,(const char*)(LPCTSTR)strTime);
	// 年
	memcpy(tmp,p,4);
	p+=5;
	tmp[4]='\0';
	stTIME.tm_year = atoi(tmp)-1900;
	// 月
	memcpy(tmp,p,2);
	p+=3;
	tmp[2]='\0';
	stTIME.tm_mon = atoi(tmp);
	// 日
	memcpy(tmp,p,2);
	p+=3;
	tmp[2]='\0';
	stTIME.tm_mday = atoi(tmp);
	
	// 时
	memcpy(tmp,p,2);
	p+=3;
	tmp[2]='\0';
	stTIME.tm_hour = atoi(tmp);
	// 分
	memcpy(tmp,p,2);
	p+=3;
	tmp[2]='\0';
	stTIME.tm_min = atoi(tmp);
	// 秒
	memcpy(tmp,p,2);
	p+=3;
	tmp[2]='\0';
	stTIME.tm_sec = atoi(tmp);
//	CString strTest;
//	strTest.Format("%d-%d-%d-%d-%d-%d",stTIME.tm_year,stTIME.tm_mon,stTIME.tm_mday,stTIME.tm_hour,stTIME.tm_min,stTIME.tm_sec);
//	AfxMessageBox(strTest);
	return mktime(&stTIME);	
}

int CRevokeCert::CheckTimeFormat(char* pszTime)
{
	int ret = 1;

	// 长度检查

	if(strlen("2004-02-04 11:06:30")!=strlen(pszTime))
		ret = 0;

	// 格式检查

	if(pszTime[4]!='-'||pszTime[7]!='-'|| pszTime[10]!=' '
		|| pszTime[13]!=':'||pszTime[16]!=':')
		ret = 0;

	return ret;
}

⌨️ 快捷键说明

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