00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifdef HAVE_CONFIG_H
00045 #include "config.h"
00046 #else if defined(_WINDOWS)
00047 #include <spl/configwin32.h>
00048 #endif
00049
00050
00051 #include "pcre_internal.h"
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
00071 pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
00072 void *where)
00073 {
00074 real_pcre internal_re;
00075 pcre_study_data internal_study;
00076 const real_pcre *re = (const real_pcre *)argument_re;
00077 const pcre_study_data *study = NULL;
00078
00079 if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
00080
00081 if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
00082 study = (const pcre_study_data *)extra_data->study_data;
00083
00084 if (re->magic_number != MAGIC_NUMBER)
00085 {
00086 re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
00087 if (re == NULL) return PCRE_ERROR_BADMAGIC;
00088 if (study != NULL) study = &internal_study;
00089 }
00090
00091 switch (what)
00092 {
00093 case PCRE_INFO_OPTIONS:
00094 *((unsigned long int *)where) = re->options & PUBLIC_COMPILE_OPTIONS;
00095 break;
00096
00097 case PCRE_INFO_SIZE:
00098 *((size_t *)where) = re->size;
00099 break;
00100
00101 case PCRE_INFO_STUDYSIZE:
00102 *((size_t *)where) = (study == NULL)? 0 : study->size;
00103 break;
00104
00105 case PCRE_INFO_CAPTURECOUNT:
00106 *((int *)where) = re->top_bracket;
00107 break;
00108
00109 case PCRE_INFO_BACKREFMAX:
00110 *((int *)where) = re->top_backref;
00111 break;
00112
00113 case PCRE_INFO_FIRSTBYTE:
00114 *((int *)where) =
00115 ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
00116 ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
00117 break;
00118
00119
00120
00121
00122 case PCRE_INFO_FIRSTTABLE:
00123 *((const uschar **)where) =
00124 (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)?
00125 ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
00126 break;
00127
00128 case PCRE_INFO_MINLENGTH:
00129 *((int *)where) =
00130 (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
00131 study->minlength : -1;
00132 break;
00133
00134 case PCRE_INFO_LASTLITERAL:
00135 *((int *)where) =
00136 ((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
00137 break;
00138
00139 case PCRE_INFO_NAMEENTRYSIZE:
00140 *((int *)where) = re->name_entry_size;
00141 break;
00142
00143 case PCRE_INFO_NAMECOUNT:
00144 *((int *)where) = re->name_count;
00145 break;
00146
00147 case PCRE_INFO_NAMETABLE:
00148 *((const uschar **)where) = (const uschar *)re + re->name_table_offset;
00149 break;
00150
00151 case PCRE_INFO_DEFAULT_TABLES:
00152 *((const uschar **)where) = (const uschar *)(_pcre_default_tables);
00153 break;
00154
00155
00156
00157
00158 case PCRE_INFO_OKPARTIAL:
00159 *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
00160 break;
00161
00162 case PCRE_INFO_JCHANGED:
00163 *((int *)where) = (re->flags & PCRE_JCHANGED) != 0;
00164 break;
00165
00166 case PCRE_INFO_HASCRORLF:
00167 *((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
00168 break;
00169
00170 default: return PCRE_ERROR_BADOPTION;
00171 }
00172
00173 return 0;
00174 }
00175
00176