home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 April
/
PCWorld_2000-04_cd.bin
/
Komunik
/
Servery
/
sambar
/
_setup.1
/
testisa.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-03-08
|
3KB
|
142 lines
/*
** TESTISA
**
** This is a simple ISAPI test DLL that takes the input and displays
** it to the user.
**
** Confidential Property of Tod Sambar
** (c) Copyright Tod Sambar 1998
** All rights reserved.
**
**
** History:
** Chg# Date Description Resp
** ---- ------- ------------------------------------------------------- ----
** 5FEB98 Created sambar
*/
#include <windows.h>
#include <httpext.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
/*
** Globals
*/
#define NO_DATA_FOUND "<P>No Data Provided."
/*
** Use a critical section to protect global data.
*/
CRITICAL_SECTION gCS;
/*
** DLL Entry point.
*/
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
InitializeCriticalSection(&gCS);
break;
case DLL_PROCESS_DETACH:
DeleteCriticalSection(&gCS);
break;
default:
break;
}
return TRUE;
}
/*
** GetExtensionVersion
**
** ISAPI/Win32 API method to ensure compatibility with the Server.
*/
BOOL WINAPI
GetExtensionVersion(HSE_VERSION_INFO *pVer)
{
pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
lstrcpyn(pVer->lpszExtensionDesc, "Sambar Server ISAPI Test extension.",
HSE_MAX_EXT_DLL_NAME_LEN);
return TRUE;
}
/*
** HttpExtensionProc
**
** Called in response to the client request.
*/
DWORD WINAPI
HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
{
DWORD buflen;
DWORD datalen;
CHAR buffer[8192];
/* Prepare the response header */
wsprintf(buffer,
"Content-Type: text/html\r\n"
"\r\n"
"<head><title>Sambar ISAPI TEST</title></head>\n"
"<body><h1>Sambar ISAPI TEST</h1>\n"
"<hr>\n");
buflen = lstrlen(buffer);
/* Get the GET/POST data */
if (!stricmp(pECB->lpszMethod, "GET"))
{
/* Append the QUERY_STRING data */
datalen = lstrlen(pECB->lpszQueryString);
if (datalen > 8000)
datalen = 8000;
if (datalen > 0)
{
strncpy(&buffer[buflen], pECB->lpszQueryString, datalen);
buflen += datalen;
}
}
else /* POST */
{
/* Note: cbTotalBytes = cbAvailable in the Sambar Server */
if(pECB->cbTotalBytes > 0)
{
datalen = pECB->cbAvailable;
if (datalen > 8000)
datalen = 8000;
strncpy(&buffer[buflen], pECB->lpbData, datalen);
buflen += datalen;
}
}
if (datalen == 0)
{
datalen = lstrlen(NO_DATA_FOUND);
strncpy(&buffer[buflen], NO_DATA_FOUND, datalen);
buflen += datalen;
}
strncpy(&buffer[buflen], "</BODY></HTML>", 14);
buflen += 14;
if (!pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER,
"200 OK", &buflen, (LPDWORD)buffer))
{
pECB->dwHttpStatusCode = 500;
return HSE_STATUS_ERROR;
}
pECB->dwHttpStatusCode = 200;
return HSE_STATUS_SUCCESS;
}