ustaticcppdrv98.cpp

来自「可以实现对邮件的加密解密以及签名」· C++ 代码 · 共 97 行

CPP
97
字号
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: UStaticCppDrv98.cpp,v 1.2 2002/08/06 20:10:50 dallen Exp $
____________________________________________________________________________*/

#include "pgpClassesConfig.h"
#include "UStaticCpp.h"

_USING_PGP

_UNNAMED_BEGIN

// Types

typedef void (_cdecl *PtrVoidFunc)(void);

struct AtExitEntry
{
	PtrVoidFunc func;
	AtExitEntry *next;
};

// Static variables

AtExitEntry *AtExitEntryList = NULL;

_UNNAMED_END


// Exported variables

#pragma data_seg("INITAAAA")
PtrVoidFunc	__xc_a[]	= {NULL};
#pragma data_seg()

#pragma data_seg("INITZZZZ")
PGPUInt32	_aZero		= 0;
#pragma data_seg()


// Functions

int 
_cdecl 
atexit(PtrVoidFunc func)
{
	AtExitEntry	*newEntry;

	newEntry = new AtExitEntry;

	if (IsNull(newEntry))
		return 0;

	newEntry->func = func;

	newEntry->next = AtExitEntryList;
	AtExitEntryList = newEntry;

	return 1;
}

void 
UStaticCpp::CallGlobalConstructors()
{
	PtrVoidFunc	*pfbegin;

	pfbegin = __xc_a;

	while (TRUE)
	{
		++pfbegin;

		if (*pfbegin == NULL)
			break;

		(**pfbegin)();
	}
}

void 
UStaticCpp::CallGlobalDestructors()
{
	AtExitEntry	*curEntry, *nextEntry;

	curEntry = AtExitEntryList;

	while (IsntNull(curEntry))
	{
		curEntry->func();
		nextEntry = curEntry->next;
		delete curEntry;
		curEntry = nextEntry;
	}
}

⌨️ 快捷键说明

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