-
Notifications
You must be signed in to change notification settings - Fork 0
/
CpIsapi.cpp
68 lines (47 loc) · 1.82 KB
/
CpIsapi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "stdafx.h"
void WriteContext(EXTENSION_CONTROL_BLOCK *pECB, char *pszFormat, ...);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
return TRUE; // reason for DllMain call is not relevant at this stage
}
BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
{
pVer->dwExtensionVersion = HSE_VERSION;
strncpy(pVer->lpszExtensionDesc, "CrazyPaving ISAPI Extension", HSE_MAX_EXT_DLL_NAME_LEN);
return TRUE;
}
void StartHeaders(EXTENSION_CONTROL_BLOCK *pECB)
{
WriteContext(pECB, "<html>\r\n<body>\r\n");
}
void EndHeaders(EXTENSION_CONTROL_BLOCK *pECB)
{
WriteContext(pECB, "</body>\r\n</html>");
}
void WriteContext(EXTENSION_CONTROL_BLOCK *pECB, char *pszFormat, ...)
{
char szBuffer[1024];
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
vsprintf(szBuffer, pszFormat, arg_ptr);
va_end(arg_ptr);
DWORD dwSize = strlen(szBuffer);
pECB->WriteClient(pECB->ConnID, szBuffer, &dwSize, 0);
}
DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
{
StartHeaders(pECB);
// Show that we've received the request
WriteContext(pECB, "<p><b><font face='Verdana' color='#A00000'>Success!</font></b></p>");
WriteContext(pECB, "<p><font size='2' face='Verdana'>The uploaded file is now available to the ISAPI extension.</font></p>\r\n", pECB->lpszQueryString);
//const char* ccVerb = pECB->lpszQueryString; // this is the command being executed
if ( "DoPOC" == std::string(pECB->lpszQueryString) ) {
//TODO: this needs to be changed to a different verb
WriteContext(pECB, "<p><font size='2' face='Verdana'>The following 'verb' was detected by ISAPI: %s.</font></p>\r\n", pECB->lpszQueryString);
// good point to load the CpMagickLibrary
// TODO: this needs to go to a more appropriate place
CpLoadMagickLibrary();
}
EndHeaders(pECB);
return HSE_STATUS_SUCCESS;
}