aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/test_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/test_lib.c')
-rw-r--r--src/plugins/test_lib.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c
index efbe2cf..97d4dc5 100644
--- a/src/plugins/test_lib.c
+++ b/src/plugins/test_lib.c
@@ -24,7 +24,8 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "test_lib.h" 26#include "test_lib.h"
27 27#include <sys/types.h>
28#include <regex.h>
28 29
29/** 30/**
30 * Function that libextractor calls for each 31 * Function that libextractor calls for each
@@ -57,14 +58,45 @@ process_replies (void *cls,
57 (sd[i].type != type) || 58 (sd[i].type != type) ||
58 (sd[i].format != format) ) 59 (sd[i].format != format) )
59 continue; 60 continue;
60 if ( (EXTRACTOR_METAFORMAT_BINARY != format) && 61 if ( (sd[i].regex) &&
61 ( (sd[i].data_len != data_len) || 62 (EXTRACTOR_METAFORMAT_BINARY != format) )
62 (0 != memcmp (sd[i].data, data, data_len)) ) ) 63 {
63 continue; 64 regex_t re;
64 if ( (EXTRACTOR_METAFORMAT_BINARY == format) && 65 regmatch_t match;
65 ( (sd[i].data_len > data_len) || 66
66 (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) ) 67 if (0 !=
67 continue; 68 regcomp (&re,
69 sd[i].data,
70 REG_EXTENDED))
71 {
72 fprintf (stderr,
73 "Not a valid regex: %s\n",
74 sd[i].data);
75 abort ();
76 }
77 if ( ('\0' != data[data_len - 1]) ||
78 (0 != regexec (&re,
79 data,
80 1,
81 &match,
82 0)) )
83 {
84 regfree (&re);
85 continue;
86 }
87 regfree (&re);
88 }
89 else
90 {
91 if ( (EXTRACTOR_METAFORMAT_BINARY != format) &&
92 ( (sd[i].data_len != data_len) ||
93 (0 != memcmp (sd[i].data, data, data_len)) ) )
94 continue;
95 if ( (EXTRACTOR_METAFORMAT_BINARY == format) &&
96 ( (sd[i].data_len > data_len) ||
97 (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) )
98 continue;
99 }
68 100
69 if (NULL != sd[i].data_mime_type) 101 if (NULL != sd[i].data_mime_type)
70 { 102 {