// skeleton.cpp : Defines the initialization routines for the DLL. // #include "stdafx.h" #include "skeleton.h" #include "httpext.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSkeletonApp BEGIN_MESSAGE_MAP(CSkeletonApp, CWinApp) //{{AFX_MSG_MAP(CSkeletonApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSkeletonApp construction CSkeletonApp::CSkeletonApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CSkeletonApp object CSkeletonApp theApp; ///////////////////////////////////////////////////////////////////////////// // Function prototypes for user defined functions void Output(EXTENSION_CONTROL_BLOCK *pEcb, LPSTR controlString, ...); void SendHTMLHeader(EXTENSION_CONTROL_BLOCK *pEcb); ///////////////////////////////////////////////////////////////////////////// // Manditory Exported Functions ///////////////////////////////////////////////////////////////////////////// // // GetExtensionVersion() // // This is the standard implementation of this function. Don't change any // thing except the description of the DLL ("Skeleton DLL") unless you know // what you're doing. // BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) { pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR); lstrcpyn(pVer->lpszExtensionDesc, "Skeleton DLL", HSE_MAX_EXT_DLL_NAME_LEN); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // // HttpExtensionProc() // // This is the 'main()' function for the DLL. // DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pEcb) { SendHTMLHeader(pEcb); Output(pEcb, ""); Output(pEcb, "
"); Output(pEcb, ""); return HSE_STATUS_SUCCESS; } ///////////////////////////////////////////////////////////////////////////// // // Output(pEcb, controlString, ...); // // This routine returns a formatted [a la printf(), sprintf()] string to // the web client, ie: // // Output(pEcb, "This is %s number %d.
", "test", 1); // // outputs to the client this string: // // This is test number 1.
// void Output(EXTENSION_CONTROL_BLOCK *pEcb, LPSTR controlString, ...) { char buffer[1024]; va_list argPtr; DWORD size; va_start(argPtr, controlString); vsprintf(buffer, controlString, argPtr); size = strlen(buffer); pEcb->WriteClient(pEcb->ConnID, buffer, &size, NULL); } /////////////////////////////////////////////////////////////////////////////////////////////// // // SendHTMLHeader() // // This routine sends a bare-bones header back to the client, telling it to expect an HTML // document. // void SendHTMLHeader(EXTENSION_CONTROL_BLOCK *pEcb) { char header[4096]; // output header strcpy(header, "Content-type: text/html\n\n"); pEcb->ServerSupportFunction(pEcb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, NULL, 0, (DWORD *) header); }