home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 November
/
PCWorld_2000-11_cd.bin
/
Komunik
/
sambar444
/
_SETUP.1
/
testisa.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-06-26
|
3KB
|
149 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
*/
#ifdef WIN32
#include <windows.h>
#else
#define MAX_PATH 1024
#define TRUE 1
#define lstrcpyn strncpy
#define lstrlen strlen
#define stricmp strcasecmp
#define wsprintf sprintf
#endif /* WIN32 */
#include <httpext.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
/*
** Globals
*/
#define NO_DATA_FOUND "<P>No Data Provided."
/*
** DLL Entry point.
*/
#ifdef WIN32
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
return TRUE;
}
#endif /* WIN32 */
/*
** 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;
}