源码 Sambar ISAPI "hello.dll"

源码 Sambar ISAPI "hello.dll"

来源(null)

下载源文件 i1832_001hello.rar

hello.c

#include <windows.h>
#include <httpext.h>
#include <string.h>
#include <stdio.h>
//#include <stdarg.h>

/*
** Globals
*/
#define PAGE_END        "/n<P>Done./n</BODY></HTML>/n"


void PA_WriteClient(EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR m_strInfo);

/*
**    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 Search extension.",
            HSE_MAX_EXT_DLL_NAME_LEN);

    return TRUE;


/*
**    HttpExtensionProc
**
**     Called in response to the client request.
*/
DWORD WINAPI
HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
{

    CHAR    buffer[2048];
    int     buflen=0;

    wsprintf(buffer,
             "Content-Type: text/html/r/n"
             "/r/n"
             "<html>/n"
             "<head><title>Sambar ISAPI /"hello.dll/"</title></head>/n"
             "<body>/n"
             "<h1>Sambar ISAPI /"hello.dll/"</h1>/n"
             "<hr>/n"
             "<P>Begin ...</P>/n");

    if (!pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER,
        "200 OK", &buflen, (LPDWORD)buffer)) 
    {
        pECB->dwHttpStatusCode = 500;
        return HSE_STATUS_ERROR;
    }
    
    PA_WriteClient(pECB, "<p>Hello World!</p>/n");

    PA_WriteClient(pECB, "<strong>REMOTE_HOST:</strong>/n");
    
    buflen = sizeof(buffer)-1;
    pECB->GetServerVariable(pECB->ConnID, "REMOTE_HOST", buffer, &buflen);
    PA_WriteClient(pECB, buffer);

    PA_WriteClient(pECB, PAGE_END);

    pECB->dwHttpStatusCode = 200;

    return HSE_STATUS_SUCCESS;
}

void PA_WriteClient(EXTENSION_CONTROL_BLOCK *pECB, LPCTSTR m_strInfo){
    DWORD m_dwInfoLen = strlen(m_strInfo);
    pECB->WriteClient(pECB->ConnID, (LPVOID)m_strInfo, &m_dwInfoLen, 0);
}


hello.def
; hello.def : Declares the module parameters for the DLL.

LIBRARY      "hello"
DESCRIPTION  'hello Windows Dynamic Link Library'

EXPORTS
    GetExtensionVersion
    HttpExtensionProc
    ; Explicit exports can go here


hello.dsp
# Microsoft Developer Studio Project File - Name="hello" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **

# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102

CFG=hello - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE 
!MESSAGE NMAKE /f "hello.mak".
!MESSAGE 
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE 
!MESSAGE NMAKE /f "hello.mak" CFG="hello - Win32 Debug"
!MESSAGE 
!MESSAGE Possible choices for configuration are:
!MESSAGE 
!MESSAGE "hello - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "hello - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE 

# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe

!IF  "$(CFG)" == "hello - Win32 Release"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "hello___Win32_Release"
# PROP BASE Intermediate_Dir "hello___Win32_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HELLO_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HELLO_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"hello.dll"

!ELSEIF  "$(CFG)" == "hello - Win32 Debug"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HELLO_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HELLO_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"hello.dll" /pdbtype:sept

!ENDIF 

# Begin Target

# Name "hello - Win32 Release"
# Name "hello - Win32 Debug"
# Begin Group "Source Files"

# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File

SOURCE=./hello.c
# End Source File
# End Group
# Begin Group "Header Files"

# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File

SOURCE=./hello.def
# End Source File
# End Group
# Begin Group "Resource Files"

# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project



执行结果:

Sambar ISAPI "hello.dll"


Begin ...

Hello World!

REMOTE_HOST: 127.0.0.1

Done.



 

Link: http://www.asm32.net/article_disp.asp?ID=1832


 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值