1 /* @include ajreg ************************************************************* 2 ** 3 ** AJAX REG (ajax regular expression) functions 4 ** 5 ** Uses the Perl-Comparible Regular Expressions Library (PCRE) 6 ** included as a sepoarate library in the EMBOSS distribution. 7 ** 8 ** @author Copyright (C) 1998 Peter Rice 9 ** @version $Revision: 1.24 $ 10 ** @modified Jun 25 pmr First version 11 ** @modified 1999-2011 pmr Replace Henry Spencer library with PCRE 12 ** @modified $Date: 2011/10/18 14:23:40 $ by $Author: rice $ 13 ** @@ 14 ** 15 ** This library is free software; you can redistribute it and/or 16 ** modify it under the terms of the GNU Lesser General Public 17 ** License as published by the Free Software Foundation; either 18 ** version 2.1 of the License, or (at your option) any later version. 19 ** 20 ** This library is distributed in the hope that it will be useful, 21 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 22 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 ** Lesser General Public License for more details. 24 ** 25 ** You should have received a copy of the GNU Lesser General Public 26 ** License along with this library; if not, write to the Free Software 27 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 28 ** MA 02110-1301, USA. 29 ** 30 ******************************************************************************/ 31 32 #ifndef AJREG_H 33 #define AJREG_H 34 35 /* ========================================================================= */ 36 /* ============================= include files ============================= */ 37 /* ========================================================================= */ 38 39 #include "ajdefine.h" 40 #include "ajstr.h" 41 42 #include "pcre_config.h" 43 #include "pcre_internal.h" 44 #include "pcreposix.h" 45 46 AJ_BEGIN_DECLS 47 48 49 50 51 /* ========================================================================= */ 52 /* =============================== constants =============================== */ 53 /* ========================================================================= */ 54 55 56 57 58 #define AJREG_OVECSIZE 30 59 60 61 62 63 /* ========================================================================= */ 64 /* ============================== public data ============================== */ 65 /* ========================================================================= */ 66 67 68 69 70 /* @data AjPRegexp ************************************************************ 71 ** 72 ** PCRE expression internals, wrapped for AJAX calls 73 ** 74 ** @alias AjSRegexp 75 ** @alias AjORegexp 76 ** 77 ** @attr pcre [real_pcre*] PCRE compiled expression 78 ** @attr extra [pcre_extra*] PCRE study data (if available, else NULL) 79 ** @attr ovector [int*] Output vector offsets 80 ** @attr orig [const char*] Original string 81 ** @attr ovecsize [int] Output vector size 82 ** @attr matches [int] Number of matches 83 ******************************************************************************/ 84 85 typedef struct AjSRegexp 86 { 87 real_pcre *pcre; 88 pcre_extra *extra; 89 int *ovector; 90 const char* orig; 91 int ovecsize; 92 int matches; 93 } AjORegexp; 94 95 #define AjPRegexp AjORegexp* 96 97 98 99 100 /* ========================================================================= */ 101 /* =========================== public functions ============================ */ 102 /* ========================================================================= */ 103 104 105 106 107 /* 108 ** Prototype definitions 109 */ 110 111 /* constructors */ 112 113 AjPRegexp ajRegComp(const AjPStr rexp); 114 AjPRegexp ajRegCompC(const char* rexp); 115 116 AjPRegexp ajRegCompCase(const AjPStr rexp); 117 AjPRegexp ajRegCompCaseC(const char* rexp); 118 119 /* execute expression match */ 120 121 AjBool ajRegExec(AjPRegexp prog, const AjPStr str); 122 AjBool ajRegExecC(AjPRegexp prog, const char* str); 123 124 AjBool ajRegExecall(AjPRegexp prog, const AjPStr str); 125 AjBool ajRegExecallC(AjPRegexp prog, const char* str); 126 127 /* test substrings */ 128 129 ajint ajRegGetMatches(const AjPRegexp rp); 130 ajint ajRegLenI(const AjPRegexp rp, ajint isub); 131 ajint ajRegOffset(const AjPRegexp rp); 132 ajint ajRegOffsetI(const AjPRegexp rp, ajint isub); 133 134 /* get substrings */ 135 136 AjBool ajRegPre(const AjPRegexp rp, AjPStr* dest); 137 AjBool ajRegPost(const AjPRegexp rp, AjPStr* post); 138 AjBool ajRegPostC(const AjPRegexp rp, const char** post); 139 AjBool ajRegSubI(const AjPRegexp rp, ajint isub, AjPStr* dest); 140 141 /* destructor */ 142 143 void ajRegFree(AjPRegexp* pexp); 144 void ajRegTrace(const AjPRegexp rexp); 145 146 void ajRegExit(void); 147 148 /* 149 ** End of prototype definitions 150 */ 151 152 153 154 155 AJ_END_DECLS 156 157 #endif /* !AJREG_H */ 158