00001 /*************************************************************************** 00002 * Copyright (c) 2009-2010, Open Information Security Foundation 00003 * Copyright (c) 2009-2012, Qualys, Inc. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the Qualys, Inc. nor the names of its 00016 * contributors may be used to endorse or promote products derived from 00017 * this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00023 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00029 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 ***************************************************************************/ 00031 00037 #ifndef _HOOKS_H 00038 #define _HOOKS_H 00039 00040 #include "dslib.h" 00041 00042 #ifdef _HTP_H 00043 #define HOOK_ERROR HTP_ERROR 00044 #define HOOK_OK HTP_OK 00045 #define HOOK_DECLINED HTP_DECLINED 00046 #else 00047 #define HOOK_ERROR -1 00048 #define HOOK_OK 0 00049 #define HOOK_DECLINED 1 00050 #endif 00051 00052 typedef struct htp_hook_t htp_hook_t; 00053 typedef struct htp_callback_t htp_callback_t; 00054 typedef int (*htp_callback_fn_t) (void *); 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 struct htp_hook_t { 00061 list_t *callbacks; 00062 }; 00063 00064 struct htp_callback_t { 00065 htp_callback_fn_t fn; 00066 }; 00067 00068 int hook_register(htp_hook_t **hook, htp_callback_fn_t callback_fn); 00069 int hook_run_one(htp_hook_t *hook, void *data); 00070 int hook_run_all(htp_hook_t *hook, void *data); 00071 00072 htp_hook_t *hook_create(void); 00073 htp_hook_t *hook_copy(htp_hook_t *hook); 00074 void hook_destroy(htp_hook_t *hook); 00075 00076 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif /* _HOOKS_H */ 00082