|
Packit |
383869 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
383869 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
383869 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
383869 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
383869 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
383869 |
* the License. You may obtain a copy of the License at
|
|
Packit |
383869 |
*
|
|
Packit |
383869 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
383869 |
*
|
|
Packit |
383869 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
383869 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
383869 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
383869 |
* See the License for the specific language governing permissions and
|
|
Packit |
383869 |
* limitations under the License.
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#ifndef APR_STRMATCH_H
|
|
Packit |
383869 |
#define APR_STRMATCH_H
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* @file apr_strmatch.h
|
|
Packit |
383869 |
* @brief APR-UTIL string matching routines
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#include "apu.h"
|
|
Packit |
383869 |
#include "apr_pools.h"
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#ifdef __cplusplus
|
|
Packit |
383869 |
extern "C" {
|
|
Packit |
383869 |
#endif
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* @defgroup APR_Util_StrMatch String matching routines
|
|
Packit |
383869 |
* @ingroup APR_Util
|
|
Packit |
383869 |
* @{
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** @see apr_strmatch_pattern */
|
|
Packit |
383869 |
typedef struct apr_strmatch_pattern apr_strmatch_pattern;
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Precompiled search pattern
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
struct apr_strmatch_pattern {
|
|
Packit |
383869 |
/** Function called to compare */
|
|
Packit |
383869 |
const char *(*compare)(const apr_strmatch_pattern *this_pattern,
|
|
Packit |
383869 |
const char *s, apr_size_t slen);
|
|
Packit |
383869 |
const char *pattern; /**< Current pattern */
|
|
Packit |
383869 |
apr_size_t length; /**< Current length */
|
|
Packit |
383869 |
void *context; /**< hook to add precomputed metadata */
|
|
Packit |
383869 |
};
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#if defined(DOXYGEN)
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Search for a precompiled pattern within a string
|
|
Packit |
383869 |
* @param pattern The pattern
|
|
Packit |
383869 |
* @param s The string in which to search for the pattern
|
|
Packit |
383869 |
* @param slen The length of s (excluding null terminator)
|
|
Packit |
383869 |
* @return A pointer to the first instance of the pattern in s, or
|
|
Packit |
383869 |
* NULL if not found
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(const char *) apr_strmatch(const apr_strmatch_pattern *pattern,
|
|
Packit |
383869 |
const char *s, apr_size_t slen);
|
|
Packit |
383869 |
#else
|
|
Packit |
383869 |
#define apr_strmatch(pattern, s, slen) (*((pattern)->compare))((pattern), (s), (slen))
|
|
Packit |
383869 |
#endif
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Precompile a pattern for matching using the Boyer-Moore-Horspool algorithm
|
|
Packit |
383869 |
* @param p The pool from which to allocate the pattern
|
|
Packit |
383869 |
* @param s The pattern string
|
|
Packit |
383869 |
* @param case_sensitive Whether the matching should be case-sensitive
|
|
Packit |
383869 |
* @return a pointer to the compiled pattern, or NULL if compilation fails
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(const apr_strmatch_pattern *) apr_strmatch_precompile(apr_pool_t *p, const char *s, int case_sensitive);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** @} */
|
|
Packit |
383869 |
#ifdef __cplusplus
|
|
Packit |
383869 |
}
|
|
Packit |
383869 |
#endif
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#endif /* !APR_STRMATCH_H */
|