LCOV - code coverage report
Current view: top level - src - regexp.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 11 14 78.6 %
Date: 2015-10-31 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "alloc.h"
       3             : #include "log.h"
       4             : #include "regexp.h"
       5             : 
       6           2 : int compile_regex(regex_t **regex, const char *str)
       7             : {
       8           2 :         if(!str || !*str) return 0;
       9           6 :         if(!(*regex=(regex_t *)malloc_w(sizeof(regex_t), __func__))
      10           6 :           || 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           2 :         ))
      17             :         {
      18           0 :                 logp("unable to compile regex\n");
      19           0 :                 return -1;
      20             :         }
      21           2 :         return 0;
      22             : }
      23             : 
      24          23 : int check_regex(regex_t *regex, const char *buf)
      25             : {
      26          23 :         if(!regex) return 1;
      27          23 :         switch(regexec(regex, buf, 0, NULL, 0))
      28             :         {
      29           3 :                 case 0: return 1;
      30          20 :                 case REG_NOMATCH: return 0;
      31           0 :                 default: return 0;
      32             :         }
      33             : }

Generated by: LCOV version 1.10