| 1 | /* |
| 2 | * Copyright (c) 2015-2016, Intel Corporation |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * * Redistributions of source code must retain the above copyright notice, |
| 8 | * this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * * Neither the name of Intel Corporation nor the names of its contributors |
| 13 | * may be used to endorse or promote products derived from this software |
| 14 | * without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | * POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | /** \file |
| 30 | * \brief NFA Callback definitions, used at runtime. |
| 31 | */ |
| 32 | |
| 33 | #ifndef NFA_CALLBACK_H |
| 34 | #define NFA_CALLBACK_H |
| 35 | |
| 36 | #include "ue2common.h" |
| 37 | |
| 38 | /** \brief The type for an NFA callback. |
| 39 | * |
| 40 | * This is a function that takes as arguments the current start and end offsets |
| 41 | * where the match occurs, the id of the match and the context pointer that was |
| 42 | * passed into the NFA API function that executed the NFA. |
| 43 | * |
| 44 | * The start offset is the "start of match" (SOM) offset for the match. It is |
| 45 | * only provided by engines that natively support SOM tracking (e.g. Gough). |
| 46 | * |
| 47 | * The end offset will be the offset after the character that caused the match. |
| 48 | * Thus, if we have a buffer containing 'abc', then a pattern that matches an |
| 49 | * empty string will have an offset of 0, a pattern that matches 'a' will have |
| 50 | * an offset of 1, and a pattern that matches 'abc' will have an offset of 3, |
| 51 | * which will be a value that is 'beyond' the size of the buffer. That is, if |
| 52 | * we have n characters in the buffer, there are n+1 different potential |
| 53 | * offsets for matches. |
| 54 | * |
| 55 | * This function should return an int - currently the possible return values |
| 56 | * are 0, which means 'stop running the engine' or non-zero, which means |
| 57 | * 'continue matching'. |
| 58 | */ |
| 59 | typedef int (*NfaCallback)(u64a start, u64a end, ReportID id, void *context); |
| 60 | |
| 61 | /** |
| 62 | * standard \ref NfaCallback return value indicating that engine execution |
| 63 | * should continue. (any non-zero value will serve this purpose) |
| 64 | */ |
| 65 | #define MO_CONTINUE_MATCHING 1 |
| 66 | |
| 67 | /** |
| 68 | * \ref NfaCallback return value indicating that engine execution should halt. |
| 69 | */ |
| 70 | #define MO_HALT_MATCHING 0 |
| 71 | |
| 72 | #endif // NFA_CALLBACK_H |
| 73 | |