summaryrefslogtreecommitdiff
path: root/dm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dm.c')
-rw-r--r--dm.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/dm.c b/dm.c
index cd6f914..51f8482 100644
--- a/dm.c
+++ b/dm.c
@@ -9,21 +9,35 @@
#include "syntax.h"
#include "mtable.h"
+/* options avaliable */
+#define ASSERT_ON
+#define __EXIT_ABBORT
+#include "assert.h"
+
/*****************************************************************************/
int ast2tb( ast_root *ast, mt_table *mt )
{
+ AS_NULL(ast)
+ AS_NULL(mt)
+
int i,j,k;
ast_range *arng = NULL;
mt_range *mrng = NULL;
for (i=0;i<ast->total_tokens;i++)
{
- arng = ast->range[i];
+ arng = (ast_range *)ast->range[i];
+
+ AS_NULL(arng)
+ //AS_NULL(arng->val)
+ //AS_NULL(arng->iff)
- if ((arng->val != NULL) && (arng->iff == NULL))
+ if (arng->val != NULL)
+ if (arng->iff == NULL)
{
mrng = malloc(sizeof(mt_range));
+ AS_NULL(mrng)
memset(mrng,0,sizeof(mt_range));
mrng->start = arng->start;
@@ -43,6 +57,7 @@ int ast2tb( ast_root *ast, mt_table *mt )
if (arng->iff[j]->expr->size_cmp > 0)
{
mrng = malloc(sizeof(mt_range));
+ AS_NULL(mrng)
memset(mrng,0,sizeof(mt_range));
//set start end positions
@@ -50,6 +65,7 @@ int ast2tb( ast_root *ast, mt_table *mt )
mrng->end = arng->end;
cmp = malloc(arng->iff[j]->expr->size_cmp);
+ AS_NULL(cmp)
for (k=0;k<arng->iff[j]->expr->size_cmp;k++)
cmp[k] = arng->iff[j]->expr->cmp[k]->val;
mrng->cmp = cmp;
@@ -74,6 +90,9 @@ int ast2tb( ast_root *ast, mt_table *mt )
* maycome */
int match( mt_table *mt, char *buf, size_t size )
{
+ AS_NULL(mt)
+ AS_NULL(buf)
+
//anonymouse function
int pr(char *str, int sz)
{
@@ -243,12 +262,13 @@ int main(int argc, char **argv)
ast = ast_syntax( tl );
//printf("ast = 0x%08x\n", ast);
- //print_ast( ast );
+ print_ast( ast );
ast2tb( ast, mt );
- //mt_print( mt );
+ mt_print( mt );
match( mt, binbuf, binbuf_size );
+ //ast_destroy( ast );
tl_destroy( tl );
mt_destroy( mt );