00001 /* This is the public header file for JavaScriptCore's variant of the PCRE 00002 library. While this library started out as a copy of PCRE, many of the 00003 features of PCRE have been removed. This library now supports only the 00004 regular expression features required by the JavaScript language 00005 specification, and has only the functions needed by JavaScriptCore and the 00006 rest of WebKit. 00007 00008 Copyright (c) 1997-2005 University of Cambridge 00009 Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. 00010 00011 ----------------------------------------------------------------------------- 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 00015 * Redistributions of source code must retain the above copyright notice, 00016 this list of conditions and the following disclaimer. 00017 00018 * Redistributions in binary form must reproduce the above copyright 00019 notice, this list of conditions and the following disclaimer in the 00020 documentation and/or other materials provided with the distribution. 00021 00022 * Neither the name of the University of Cambridge nor the names of its 00023 contributors may be used to endorse or promote products derived from 00024 this software without specific prior written permission. 00025 00026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 POSSIBILITY OF SUCH DAMAGE. 00037 ----------------------------------------------------------------------------- 00038 */ 00039 00040 // FIXME: This file needs to be renamed to JSRegExp.h; it's no longer PCRE. 00041 00042 #ifndef JSRegExp_h 00043 #define JSRegExp_h 00044 00045 #include "../../../include/v8.h" 00046 00047 // JSCRE is very chatty in debug mode, so in order to keep it slient 00048 // while still importing v8.h correctly (it contains #ifdef DEBUGs) 00049 // we allow DEBUG to be set and undef it manually. 00050 #undef DEBUG 00051 00052 typedef uint16_t UChar; 00053 00054 struct JSRegExp; 00055 typedef struct JSRegExp JscreRegExp; 00056 00057 enum JSRegExpIgnoreCaseOption { JSRegExpDoNotIgnoreCase, JSRegExpIgnoreCase }; 00058 enum JSRegExpMultilineOption { JSRegExpSingleLine, JSRegExpMultiline }; 00059 00060 /* jsRegExpExecute error codes */ 00061 const int JSRegExpErrorNoMatch = -1; 00062 const int JSRegExpErrorHitLimit = -2; 00063 const int JSRegExpErrorNoMemory = -3; 00064 const int JSRegExpErrorInternal = -4; 00065 00066 typedef void* malloc_t(size_t size); 00067 typedef void free_t(void* address); 00068 00069 JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength, 00070 JSRegExpIgnoreCaseOption, JSRegExpMultilineOption, 00071 unsigned* numSubpatterns, const char** errorMessage, 00072 malloc_t* allocate_function, free_t* free_function); 00073 00074 int jsRegExpExecute(const JSRegExp*, 00075 const UChar* subject, int subjectLength, int startOffset, 00076 int* offsetsVector, int offsetsVectorLength); 00077 00078 void jsRegExpFree(JSRegExp*); 00079 00080 #endif