// This is a part of the Active Template Library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Active Template Library Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Active Template Library product.
#ifndef __ATLSTENCIL_H__
#include <atlstencil.h>
#endif
#ifndef __ATLISAPI_H__
#define __ATLISAPI_H__
#pragma once
#include <atlbase.h>
#include <time.h> // needed for cookie support
#include <httpext.h> // needed for ECB and IIS support
#include <atlspriv.h>
#include <atlserr.h>
#include <atlfile.h>
#include <atlstr.h>
#include <atldbcli.h>
#include <atlutil.h>
#include <atlcache.h>
#include <atlsrvres.h>
#include <atlsiface.h>
#include <objbase.h>
#include <atlsecurity.h>
#include <errno.h>
#ifndef ATL_NO_SOAP
#include <msxml2.h>
#endif
#ifndef ATL_NO_ACLAPI
#include <aclapi.h>
#endif
#ifndef ATL_NO_MMSYS
#pragma warning(push)
#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union
#include <mmsystem.h>
#pragma warning(pop)
#ifndef _ATL_NO_DEFAULT_LIBS
#pragma comment(lib, "winmm.lib")
#ifndef ATL_NO_SOAP
#pragma comment(lib, "msxml2.lib")
#endif
#endif // !_ATL_NO_DEFAULT_LIBS
#endif
#include <atlpath.h>
#pragma warning(push)
#pragma warning(disable: 4291) // allow placement new
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 4511) // copy constructor could not be generated
#pragma warning(disable: 4512) // assignment operator could not be generated
#pragma warning(disable: 4625) // copy constructor could not be generated because a base class copy constructor is inaccessible
#pragma warning(disable: 4626) // assignment operator could not be generated because a base class assignment operator is inaccessible
#pragma warning(disable: 4191) // unsafe conversion from 'functionptr1' to 'functionptr2'
#pragma warning(disable: 4702) // unreachable code
#include <initguid.h>
#include <dbgautoattach.h>
#ifndef SESSION_COOKIE_NAME
#define SESSION_COOKIE_NAME "SESSIONID"
#endif
// override this if you want to use a different CLSID for SAX
#ifndef ATLS_SAXXMLREADER_CLSID
#define ATLS_SAXXMLREADER_CLSID __uuidof(SAXXMLReader)
#endif // ATLS_SAXXMLREADER_CLSID
// This function is used in CValidateObject to determine if an empty
// request parameter really should be empty. You can
// specialize this function in your own code such as
// the following specialization for type long:
// template <>
// inline bool IsNullByType<long>(long type) throw()
// {
// return type == 0;
// }
// You should provide your own specialization for this
// function if the comparison of type==0 is not adequate
// to discover whether or not your type is 0.
template <class TComp>
inline bool IsNullByType(__in TComp type) throw()
{
return type == 0;
}
#pragma pack(push,_ATL_PACKING)
namespace ATL {
// Default file extension for server response files
#ifndef ATL_DEFAULT_STENCIL_EXTENSION
#define ATL_DEFAULT_STENCIL_EXTENSION ".srf"
#endif
extern __declspec(selectany) const char * const c_AtlSRFExtension = ATL_DEFAULT_STENCIL_EXTENSION;
extern __declspec(selectany) const TCHAR * const c_tAtlSRFExtension = _T(ATL_DEFAULT_STENCIL_EXTENSION);
#define ATLS_EXTENSION_LEN (sizeof(ATL_DEFAULT_STENCIL_EXTENSION)-2)
// Default file extension for handler DLLs
#ifndef ATL_DEFAULT_DLL_EXTENSION
#define ATL_DEFAULT_DLL_EXTENSION ".dll"
#endif
extern __declspec(selectany) const char * const c_AtlDLLExtension = ATL_DEFAULT_DLL_EXTENSION;
extern __declspec(selectany) const TCHAR * const c_tAtlDLLExtension = _T(ATL_DEFAULT_DLL_EXTENSION);
#define ATLS_DLL_EXTENSION_LEN (sizeof(ATL_DEFAULT_DLL_EXTENSION)-2)
// maximum handler name length
#ifndef ATL_MAX_HANDLER_NAME_LEN
#define ATL_MAX_HANDLER_NAME_LEN 64
#endif
#ifndef ATL_HANDLER_NAME_DEFAULT
#define ATL_HANDLER_NAME_DEFAULT "Default"
#endif // ATL_DEFAULT_HANDLER_NAME
// maximum timeout for async guard mutex
#ifndef ATLS_ASYNC_MUTEX_TIMEOUT
#define ATLS_ASYNC_MUTEX_TIMEOUT 10000
#endif
#if defined(_M_IA64) || defined (_M_AMD64)
#define ATLS_FUNCID_INITIALIZEHANDLERS "InitializeAtlHandlers"
#define ATLS_FUNCID_GETATLHANDLERBYNAME "GetAtlHandlerByName"
#define ATLS_FUNCID_UNINITIALIZEHANDLERS "UninitializeAtlHandlers"
#elif defined(_M_IX86)
#define ATLS_FUNCID_INITIALIZEHANDLERS "_InitializeAtlHandlers@8"
#define ATLS_FUNCID_GETATLHANDLERBYNAME "_GetAtlHandlerByName@12"
#define ATLS_FUNCID_UNINITIALIZEHANDLERS "_UninitializeAtlHandlers@0"
#else
#error Unknown Platform.
#endif
#define ATL_MAX_COOKIE_LEN 2048
#define ATL_MAX_COOKIE_ELEM 1024
// Defines a small value used for comparing the equality of floating point numbers.
#ifndef ATL_EPSILON
#define ATL_EPSILON .0001
#endif
#ifndef ATL_DEFAULT_PRECISION
#define ATL_DEFAULT_PRECISION 6
#endif
// Call this function to URL-encode a buffer and have the result appended to a CString passed by reference.
//
// A space in the input string is encoded as a plus sign (+).
// Other unsafe characters (as determined by AtlIsUnsafeUrlChar) are encoded as escaped octets.
// An escaped octet is a percent sign (%) followed by two digits representing the hexadecimal code of the character.
//
// string A CStringA reference to which will be appended the encoded version of szBuf.
//
// szBuf The string to be URL-encoded.
ATL_NOINLINE inline bool EscapeToCString(__inout CStringA& string, __in LPCSTR szBuf)
{
ATLENSURE( szBuf != NULL );
_ATLTRY
{
CHAR szEscaped[512];
LPSTR pszStr = szEscaped;
DWORD dwLen = 0;
while (*szBuf)
{
if (dwLen+4 >= _countof(szEscaped))
{
*pszStr = '\0';
string.Append(szEscaped, dwLen);
pszStr = szEscaped;
dwLen = 0;
}
if (AtlIsUnsafeUrlChar(*szBuf))
{
if (*szBuf == ' ')
{
dwLen++;
*pszStr++ = '+';
}
else
{
LPSTR pszTmp = pszStr;
*pszTmp++ = '%';
unsigned char ch = (unsigned char)*szBuf;
if (ch < 16)
{
*pszTmp++ = '0';
}
Checked::ultoa_s((unsigned char)ch, pszTmp, szEscaped + _countof(szEscaped) - pszTmp, 16);
pszStr+= sizeof("%FF")-1;
dwLen+= sizeof("%FF")-1;
}
}
else
{
*pszStr++ = *szBuf;
dwLen++;
}
szBuf++;
}
*pszStr = '\0';
string.Append(szEscaped, dwLen);
}
_ATLCATCHALL()
{
return false;
}
return true;
}
// UNICODE overload for EscapeToCString
// follow specifications detailed in RFC document on
// Internationalized Uniform Resource Identifiers (IURI)
inline bool EscapeToCString(__inout CStringA& string, __in_z LPCWSTR wszBuf) throw()
{
_ATLTRY
{
// convert string to UTF8
CFixedStringT<CStringA, 2048> strConvert;
// get the required length for conversion
int nSrcLen = (int) wcslen(wszBuf);
int nLen = AtlUnicodeToUTF8(wszBuf, nSrcLen, NULL, 0);
if (!nLen)
{
return false;
}
// allocate MBCS conversion string
LPSTR sz = strConvert.GetBuffer(nLen+1);
if (!sz)
{
return false;
}
// do the UNICODE to UTF8 conversion
nLen = AtlUnicodeToUTF8(wszBuf, nSrcLen, sz, nLen);
if (!nLen)
{
return false;
}
// null-terminate
sz[nLen] = '\0';
// delegate to ANSI version of EscapeToCString
if (!EscapeToCString(string, sz))
{
return false;
}
strConvert.ReleaseBuffer(nLen);
}
_ATLCATCHALL()
{
return false;
}
return true;
}
struct CDefaultErrorProvider
{
struct HTTP_ERROR_TEXT
{
UINT uHttpError; // the Http Error value
UINT uHttpSubError; // Allows for customization of error text based on srf specific errors.
LPCSTR szHeader; // the string that should appear in the http response header
UINT uR
评论2
最新资源