LCOV - code coverage report
Current view: top level - src - regexp.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 15 16 93.8 %
Date: 2017-05-01 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "alloc.h"
       3             : #include "log.h"
       4             : #include "regexp.h"
       5             : 
       6          12 : regex_t *regex_compile(const char *str)
       7             : {
       8          12 :         regex_t *regex=NULL;
       9          12 :         if((regex=(regex_t *)malloc_w(sizeof(regex_t), __func__))
      10          12 :           && !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          10 :         )) return regex;
      17             : 
      18           2 :         regex_free(&regex);
      19           2 :         return NULL;
      20             : }
      21             : 
      22          23 : int regex_check(regex_t *regex, const char *buf)
      23             : {
      24          23 :         if(!regex) return 0;
      25          23 :         switch(regexec(regex, buf, 0, NULL, 0))
      26             :         {
      27             :                 case 0: return 1;
      28          20 :                 case REG_NOMATCH: return 0;
      29           0 :                 default: return 0;
      30             :         }
      31             : }
      32             : 
      33         621 : void regex_free(regex_t **regex)
      34             : {
      35        1242 :         if(!regex || !*regex) return;
      36          12 :         regfree(*regex);
      37          12 :         free_v((void **)regex);
      38             : }

Generated by: LCOV version 1.10