Blame apache2/acmp.h

Packit Service 384592
/*
Packit Service 384592
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
Packit Service 384592
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
Packit Service 384592
*
Packit Service 384592
* You may not use this file except in compliance with
Packit Service 384592
* the License.  You may obtain a copy of the License at
Packit Service 384592
*
Packit Service 384592
*     http://www.apache.org/licenses/LICENSE-2.0
Packit Service 384592
*
Packit Service 384592
* If any of the files related to licensing are missing or if you have any
Packit Service 384592
* other questions related to licensing please contact Trustwave Holdings, Inc.
Packit Service 384592
* directly using the email address security@modsecurity.org.
Packit Service 384592
*/
Packit Service 384592
Packit Service 384592
#ifndef ACMP_H_
Packit Service 384592
#define ACMP_H_
Packit Service 384592
Packit Service 384592
#include <apr.h>
Packit Service 384592
#include <apr_pools.h>
Packit Service 384592
Packit Service 384592
#define ACMP_FLAG_BYTE               0
Packit Service 384592
#define ACMP_FLAG_CASE_SENSITIVE     1
Packit Service 384592
#define ACMP_FLAG_CASE_INSENSITIVE   0
Packit Service 384592
#ifdef ACMP_USE_UTF8
Packit Service 384592
#define ACMP_FLAG_UTF8               0x100
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Opaque struct with parser data
Packit Service 384592
 */
Packit Service 384592
typedef struct ACMP ACMP;
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Used to separate state from the trie for acmp_process_quick function
Packit Service 384592
 */
Packit Service 384592
typedef struct {
Packit Service 384592
    ACMP *parser;
Packit Service 384592
    void *ptr;
Packit Service 384592
} ACMPT;
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Callback function. Arguments are:
Packit Service 384592
 * ACMP * - acmp parser that initiated callback
Packit Service 384592
 * void * - custom data you supplied when adding callback
Packit Service 384592
 * apr_size_t - position in bytes where pattern was found
Packit Service 384592
 * apr_size_t - position in chars where pattern was found, for multibyte strings
Packit Service 384592
 */
Packit Service 384592
typedef void (*acmp_callback_t)(ACMP *, void *, apr_size_t, apr_size_t);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * flags - OR-ed values of ACMP_FLAG constants
Packit Service 384592
 * pool  - apr_pool to use as parent pool, can be set to NULL
Packit Service 384592
 */
Packit Service 384592
ACMP *acmp_create(int flags, apr_pool_t *pool);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Destroys previously created parser
Packit Service 384592
 */
Packit Service 384592
void acmp_destroy(ACMP *parser);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Creates parser with same options and same patterns
Packit Service 384592
 * parser - ACMP parser to duplicate
Packit Service 384592
 * pool - parent pool to use, if left as NULL original parser's parent pool is used
Packit Service 384592
 */
Packit Service 384592
ACMP *acmp_duplicate(ACMP *parser, apr_pool_t *pool);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Adds pattern to parser. Cannot be done after starting the search.
Packit Service 384592
 * parser - ACMP parser
Packit Service 384592
 * pattern - string with pattern to match
Packit Service 384592
 * callback - Optional, pointer to an acmp_callback_t function
Packit Service 384592
 * data - pointer to data that will be passed to callback function, only used if callback
Packit Service 384592
 *   is supplied
Packit Service 384592
 * len - Length of pattern in characters, if zero string length is used.
Packit Service 384592
 */
Packit Service 384592
apr_status_t acmp_add_pattern(ACMP *parser, const char *pattern,
Packit Service 384592
    acmp_callback_t callback, void *data, apr_size_t len);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Called to process incoming data stream. You must call acmp_done after sending
Packit Service 384592
 *   last data packet
Packit Service 384592
 *
Packit Service 384592
 * data - ptr to incoming data
Packit Service 384592
 * len  - size of data in bytes
Packit Service 384592
 */
Packit Service 384592
apr_status_t acmp_process(ACMP *parser, const char *data, apr_size_t len);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Returns number of matches on all patterns combined
Packit Service 384592
 */
Packit Service 384592
apr_size_t acmp_match_count_total(ACMP *parser);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Returns number of matches for given pattern
Packit Service 384592
 */
Packit Service 384592
apr_size_t acmp_match_count(ACMP *parser, const char *pattern);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Resets the state of parser so you can start using it with new set of data,
Packit Service 384592
 * or add new patterns.
Packit Service 384592
 */
Packit Service 384592
void acmp_reset(ACMP *parser);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Creates an ACMPT struct that will use parser's tree, without duplicating its data
Packit Service 384592
 */
Packit Service 384592
ACMPT *acmp_duplicate_quick(ACMP *parser, apr_pool_t *pool);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Process the data using ACMPT to keep state, and ACMPT's parser to keep the tree
Packit Service 384592
 */
Packit Service 384592
apr_status_t acmp_process_quick(ACMPT *acmpt, const char **match, const char *data, apr_size_t len);
Packit Service 384592
Packit Service 384592
/**
Packit Service 384592
 * Prepares parser for searching
Packit Service 384592
 */
Packit Service 384592
apr_status_t acmp_prepare(ACMP *parser);
Packit Service 384592
Packit Service 384592
Packit Service 384592
#endif /*ACMP_H_*/