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

📄 httpd.h

📁 Windows CE 6.0 Server 源码
💻 H
📖 第 1 页 / 共 2 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*--
Module Name: HTTPD.H
Abstract: Global defns for the HTTP server
--*/

#ifndef _HTTPD_H_
#define _HTTPD_H_


#ifndef UNDER_CE
#define SECURITY_WIN32
#endif

#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>

#if ! defined (UNDER_CE)
typedef PVOID INTERLOCKED_COMP, *PINTERLOCKED_COMP;
#else
typedef LONG  INTERLOCKED_COMP, *PINTERLOCKED_COMP;
typedef LONG INTERLOCKED_RESULT;
#endif // UNDER_CE

#include <stdio.h>
#include <strsafe.h>
#include <httpext.h>
#include <httpfilt.h>
#include <service.h>
#include <msxml2.h>

#include <httpdrc.h>
#include <creg.hxx>


#include <servutil.h>
#include <httpcomn.h>
#ifdef UNDER_CE
#include <sspi.h>
#include <wincrypt.h>
#else
#include <security.h>
#endif

#include <schnlsp.h>
#include <iphlpapi.h>

#ifdef UNDER_CE
#include <windbase.h>
#include <extfile.h>
#include <bldver.h>
#if defined (DEBUG)
#include <windev.h>
#endif // DEBUG
#endif // UNDER_CE

// Doctor Watson error reporting header file.
#include <errorrep.h>

// Note that any code in HTTPD related to processing a request will NOT wrap
// individual uses of safeInt in a __try/__except block, because the entire
// HTTP request processing itself is already in a __try/__except in HttpConnectionThread().  
// If there is an integer overflow, we want the HTTP request to come to a swift end.
#include <safeInt.hxx>

//------------- Arbitrary constants -----------------------

// the assumption is that this buffer size covers the vast majority of requests
#define MINBUFSIZE		1024
// maximum size of output headers
#define MAXHEADERS		512
// maximum size of a mime-type
#define MAXMIME			64
// maximum size username+password
#define MAXUSERPASS		256
// the assumption is that this buffer size covers most dir listings
#define DIRBUFSIZE		4096
// Size of response headers ("normal" headers, cookies and other extra headers are dynamic)
#define HEADERBUFSIZE   4096
// Used for dynamically growing arrays
#define VALUE_GROW_SIZE   5		
// Size of buffer to hold all the bodies on web server errors
#define BODYSTRINGSIZE     4096
// Default log size
#define DEFAULTLOGSIZE     32768
// Amount of time timer thread should sleep between firing.
#define PERIODIC_TIMER_SLEEP_TIMEOUT 60000
// Smallest amount of POST data we'll ever read, puts lower bound on PostReadSize registry value.
#define MIN_POST_READ_SIZE   8192

#define HTTPD_DEV_PREFIX   L"HTP"
#define HTTPD_DEV_INDEX   0
#define HTTPD_DEV_NAME     L"HTP0:"

#define LOG_REMOTE_ADDR_SIZE 50


//------------- not-so-arbitrary constants -----------------------

#define IPPORT_HTTP		80
#define IPPORT_SSL      443


//-------------------- Debug defines ------------------------

// Debug zones
#ifdef DEBUG
  #define ZONE_ERROR	DEBUGZONE(0)
  #define ZONE_INIT		DEBUGZONE(1)
  #define ZONE_LISTEN	DEBUGZONE(2)
  #define ZONE_SOCKET	DEBUGZONE(3)
  #define ZONE_REQUEST	DEBUGZONE(4)
  #define ZONE_RESPONSE	DEBUGZONE(5)
  #define ZONE_ISAPI	DEBUGZONE(6)
  #define ZONE_VROOTS	DEBUGZONE(7)
  #define ZONE_ASP      DEBUGZONE(8)
  #define ZONE_DEVICE   DEBUGZONE(9)
  #define ZONE_SSL      DEBUGZONE(10)
  #define ZONE_VERBOSE  DEBUGZONE(11)
  #define ZONE_AUTH     DEBUGZONE(12)  
  #define ZONE_WEBDAV	DEBUGZONE(13)
  #define ZONE_PARSER	DEBUGZONE(14)
  #define ZONE_TOKEN	DEBUGZONE(15)

  #define ZONE_REQUEST_VERBOSE  (ZONE_VERBOSE && ZONE_REQUEST)
  #define ZONE_SSL_VERBOSE      (ZONE_VERBOSE && ZONE_SSL)
  #define ZONE_WEBDAV_VERBOSE   (ZONE_VERBOSE && ZONE_WEBDAV)
#endif


#define NTLM_PACKAGE_NAME       TEXT("NTLM")
#define NEGOTIATE_PACKAGE_NAME  TEXT("Negotiate")

// We need CE_STRING because GetProcAddress takes a LPCSTR as arg on NT, but UNICODE is defined
// so the TEXT macro would return a UNICODE string
#ifdef  UNDER_CE
#define SECURITY_DLL_NAME TEXT("\\windows\\secur32.dll")
#define CE_STRING(x)	  TEXT(x)
#define SECURITY_ENTRYPOINT_CE  SECURITY_ENTRYPOINT
#else
#define SECURITY_DLL_NAME TEXT("security.dll")
#define CE_STRING(x)	  (LPCSTR) (x)
#define SECURITY_ENTRYPOINT_CE  SECURITY_ENTRYPOINT_ANSIA
#endif

#define ASP_DLL_NAME      L"\\windows\\asp.dll"

/////////////////////////////////////////////////////////////////////////////
// Misc string handling helpers
/////////////////////////////////////////////////////////////////////////////

PSTR MySzDupA(PCSTR pszIn, int iLen=0);
PWSTR MySzDupW(PCWSTR wszIn, int iLen=0);
PWSTR MySzDupAtoW(PCSTR pszIn, int iInLen=-1);
PSTR MySzDupWtoA(PCWSTR wszIn, int iInLen=-1);
BOOL MyStrCatA(PSTR *ppszDest, PSTR pszSource, PSTR pszDivider=NULL);

// Misc HTTP helper macros
#define CHECKSIG(h)    (((CHttpRequest*)h)->m_dwSig == CHTTPREQUEST_SIG)
#define CHECKHCONN(h) if(!h || ((CHttpRequest*)h)->m_dwSig != CHTTPREQUEST_SIG) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
#define CHECKPFC(h)  if (!h || ((CHttpRequest*)h->ServerContext)->m_dwSig != CHTTPREQUEST_SIG) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
#define CHECKPTR(p) if (!p) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
#define CHECKPTRS2(p1, p2) if(!p1 || !p2) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
#define CHECKPTRS3(p1, p2, p3) if(!p1 || !p2 || !p3) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }

#define	CHECKFILTER(pfc)    { if (! ((CHttpRequest*)pfc->ServerContext)->m_pFInfo->m_fFAccept)	\
									{	    SetLastError(ERROR_OPERATION_ABORTED);	return FALSE;	} }

inline BOOL IsDirectory(DWORD dwFileAttributes) {
	return (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
}

inline BOOL IsDirectory(WIN32_FIND_DATAW *pFileData) {
	return IsDirectory(pFileData->dwFileAttributes);
}

inline BOOL IsDirectory(WIN32_FILE_ATTRIBUTE_DATA *pFileData) {
	return IsDirectory(pFileData->dwFileAttributes);
}

//------------- Scalar Data typedefs -----------------------
// HTTP status codes
typedef enum {
	STATUS_OK = 0,                     // 200
	STATUS_MOVED,                      // 302
	STATUS_NOTMODIFIED,                // 304
	STATUS_BADREQ,                     // 400
	STATUS_UNAUTHORIZED,               // 401
	STATUS_FORBIDDEN,                  // 403
	STATUS_NOTFOUND,                   // 404
	STATUS_INTERNALERR,                // 500
	STATUS_NOTIMPLEM,                  // 501
	STATUS_CREATED,                    // 201
	STATUS_NOCONTENT,                  // 204
	STATUS_MULTISTATUS,                // 207
	STATUS_METHODNOTALLOWED,           // 405
	STATUS_CONFLICT,                   // 409
	STATUS_LENGTH_REQUIRED,            // 411
	STATUS_PRECONDITION_FAILED,        // 412
	STATUS_REQUEST_TOO_LARGE,          // 413
	STATUS_UNSUPPORTED_MEDIA_TYPE,     // 415
	STATUS_LOCKED,                     // 423
	STATUS_INSUFFICIENT_STORAGE,       // 507
	STATUS_MAX,
}
RESPONSESTATUS;

// Data used for response static data
typedef struct {
	DWORD dwStatusNumber;
	PCSTR pszStatusText;
	PCSTR pszStatusBody;
	BOOL  fHasDefaultBody;
}
STATUSINFO;

#define IS_STATUS_2XX(status)      ((rgStatus[(status)].dwStatusNumber >= 200) && (rgStatus[(status)].dwStatusNumber < 300))

#define	SERVICE_CALLER_PROCESS_HTTPDEXE_EXE         101
#define MAX_SOCKET_LIST                             64

//------------- Const data prototypes -----------------------


extern STATUSINFO rgStatus[STATUS_MAX];

⌨️ 快捷键说明

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