"Fossies" - the Fresh Open Source Software Archive

Member "burp-2.3.6/src/regexp.c" (28 Apr 2019, 737 Bytes) of package /linux/privat/burp-2.3.6.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "regexp.c" see the Fossies "Dox" file reference documentation.

    1 #include "burp.h"
    2 #include "alloc.h"
    3 #include "log.h"
    4 #include "regexp.h"
    5 
    6 regex_t *regex_compile(const char *str)
    7 {
    8     regex_t *regex=NULL;
    9     if((regex=(regex_t *)malloc_w(sizeof(regex_t), __func__))
   10       && !regcomp(regex, str, REG_EXTENDED
   11 #ifdef HAVE_WIN32
   12 // Give Windows another helping hand and make the regular expressions
   13 // case insensitive.
   14         | REG_ICASE
   15 #endif
   16     )) return regex;
   17 
   18     regex_free(&regex);
   19     return NULL;
   20 }
   21 
   22 int regex_check(regex_t *regex, const char *buf)
   23 {
   24     if(!regex) return 0;
   25     switch(regexec(regex, buf, 0, NULL, 0))
   26     {
   27         case 0: return 1;
   28         case REG_NOMATCH: return 0;
   29         default: return 0;
   30     }
   31 }
   32 
   33 void regex_free(regex_t **regex)
   34 {
   35     if(!regex || !*regex) return;
   36         regfree(*regex);
   37     free_v((void **)regex);
   38 }