isapi_application.h

00001 /*
00002  * isapi_application.h
00003  * This file is part of dbPager Classes Library (DCL)
00004  *
00005  * Copyright (c) 2008 Dennis Prochko <wolfsoft@mail.ru>
00006  *
00007  * DCL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation version 3.
00010  *
00011  * DCL is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with DCL; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor,
00019  * Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _ISAPI_APPLICATION_H_
00023 #define _ISAPI_APPLICATION_H_
00024 
00025 #include <httpext.h>
00026 
00027 #include <dcl/delegate.h>
00028 #include <dcl/http_header.h>
00029 #include <dcl/web_application.h>
00030 
00031 namespace dbp {
00032 
00034 
00052 class isapi_application: public web_application_int {
00053         friend DWORD ::HttpExtensionProc(EXTENSION_CONTROL_BLOCK*);
00054 public:
00055         isapi_application(): isapi_req(NULL) { };
00056         virtual void on_handle_request(on_request_handler handler) {
00057                 request_handler = handler;
00058         };
00059         virtual void on_exception(on_exception_handler handler) {
00060                 exception_handler = handler;
00061         };
00062 protected:
00063         int handle_request();
00064         virtual http_request get_request();
00065         virtual void send_response(const http_response &response);
00066 private:
00067         LPEXTENSION_CONTROL_BLOCK isapi_req;
00068         on_request_handler request_handler;
00069         on_exception_handler exception_handler;
00070         std::string get_server_variable(const std::string &name) const;
00071 };
00072 
00073 } //namespace
00074 
00075 #undef IMPLEMENT_APP
00076 #define IMPLEMENT_APP(module_name, app_class)                                                           \
00077 extern "C" {                                                                                                                            \
00078                                                                                                                                                         \
00079 __declspec(dllexport)                                                                                                           \
00080 BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO* pVer) {                                       \
00081         pVer->dwExtensionVersion =                                                                                              \
00082           MAKELONG(HSE_VERSION_MINOR,HSE_VERSION_MAJOR);                                                \
00083         strncpy(pVer->lpszExtensionDesc, #module_name,                                                  \
00084           HSE_MAX_EXT_DLL_NAME_LEN);                                                                                    \
00085         return true;                                                                                                                    \
00086 }                                                                                                                                                       \
00087                                                                                                                                                         \
00088 __declspec(dllexport)                                                                                                           \
00089 BOOL WINAPI TerminateExtension(DWORD dwFlags) {                                                         \
00090         return true;                                                                                                                    \
00091 }                                                                                                                                                       \
00092                                                                                                                                                         \
00093 __declspec(dllexport)                                                                                                           \
00094 DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) {                       \
00095         app_class app;                                                                                                                  \
00096         dbp::isapi_application &_app = app.application_impl();                                  \
00097         _app.isapi_req = lpECB;                                                                                                 \
00098         return _app.handle_request();                                                                                   \
00099 }                                                                                                                                                       \
00100                                                                                                                                                         \
00101 } //extern
00102 
00103 #endif /*_ISAPI_APPLICATION_H_*/

 
Support This Project
SourceForge.net Logo