📄 modules.h
字号:
/* * * C++ Portable Types Library (PTypes) * Version 1.7.5 Released 9-Mar-2003 * * Copyright (c) 2001, 2002, 2003 Hovik Melikyan * * http://www.melikyan.com/ptypes/ * http://ptypes.sourceforge.net/ * */#ifndef W_MODULES_H#define W_MODULES_H#include <ptypes.h>#include "request.h"USING_PTYPES//// wshare modules API//// we currently only support statically linked handlers. all handlers// receive request_rec& as a parameter and must respond by either// calling one of the request_rec::rsp_XXX standard functions, or by// performing some actions and giving the ehttp exception with the HTTP// response code as a parameter. all public methods and fields of // request_rec are at your disposal. all rsp_XXX methods throw exceptions// of type ehttp, so they never return to the caller.// the following macros must be placed in init_handlers() (modules.cxx)// for each new handler. the handler callback must exist somewhere and// must be linked to wshare. these macros declare your callback functions// as extern's, so you don't need to do it elsewhere.// there are three types of handlers:// method handlers are called whenever an unknown HTTP method is found// in the request line. the rest of input data must be processed by this// handler. you can call request_rec::parse_XXX if the request is // HTTP/1.1-like.#define ADD_METHOD_HANDLER(method,callback) \ extern void callback(request_rec&); \ add_method_handler(method, callback);// path handlers are called when the request-URI points to a // non-existent object. the path parameter contains the first path // components that this handler wishes to receive. all request_rec// fields up to `range_max' inclusive contain valid values which can // be used by this handler.// the path parameter must contain the leading slash, and must not// contain the trailing slash.#define ADD_PATH_HANDLER(path,callback) \ extern void callback(request_rec&); \ add_path_handler(path, callback);// file handlers are called for specific file extensions for// EXISTING files. the ext paramter is the extension this handler// wishes to handle. the ext parameter must contain the leading dot.#define ADD_FILE_HANDLER(ext,callback) \ extern void callback(request_rec&); \ add_file_handler(ext, callback);// all handler functions must be of the following types (depending on the// handler type):typedef void (*method_callback)(request_rec& req);typedef void (*path_callback)(request_rec& req);typedef void (*file_callback)(request_rec& req);//// internal module management//struct handler_info{ handler_info* next; void* callback; string param; handler_info(handler_info*, void*, const string&);};extern handler_info* method_list;extern handler_info* path_list;extern handler_info* file_list;void add_method_handler(const string& method, method_callback);void add_path_handler(const string& path, path_callback);void add_file_handler(const string& ext, file_callback);handler_info* find_handler(handler_info* list, const string& param);void init_handlers();#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -