Commit 65d8c373 authored by Sven Robertz's avatar Sven Robertz
Browse files

epsilon; iterative parser still not supporting skipping of data

parent 087bf1ca
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#define DEBUG #define DEBUG
#undef DEBUG_STACK
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
...@@ -222,7 +223,7 @@ int do_parse(buffer *d) { ...@@ -222,7 +223,7 @@ int do_parse(buffer *d) {
unsigned int uid = pop(d); unsigned int uid = pop(d);
printf(", name = "); printf(", name = ");
accept_string(d); accept_string(d);
// ignore, for now. This should do something as pop(d); // ignore, for now. This should do something as
// char *name = (char*) pop(d); // char *name = (char*) pop(d);
// store or print name // store or print name
// free(name) // free(name)
...@@ -246,9 +247,9 @@ int do_parse(buffer *d) { ...@@ -246,9 +247,9 @@ int do_parse(buffer *d) {
accept_type(d); accept_type(d);
printf(" : "); printf(" : ");
//unsigned int dt = pop(d); //unsigned int dt = pop(d);
#if 0
unsigned int end = d->idx; unsigned int end = d->idx;
unsigned int len = end-start; unsigned int len = end-start;
#if 0
if(len <= MAX_SIG_LEN) { if(len <= MAX_SIG_LEN) {
signatures_length[uid-USER_ID_BASE] = len; signatures_length[uid-USER_ID_BASE] = len;
memcpy(signatures_name[uid-USER_ID_BASE], &d->c[nstart+3], nlen+1); memcpy(signatures_name[uid-USER_ID_BASE], &d->c[nstart+3], nlen+1);
...@@ -263,6 +264,7 @@ int do_parse(buffer *d) { ...@@ -263,6 +264,7 @@ int do_parse(buffer *d) {
} }
printf("signature for uid %x: %s (start=%x,end=%x, nlen=%d,len=%d)\n", uid, get_signature_name(uid), start,end, nlen, len); printf("signature for uid %x: %s (start=%x,end=%x, nlen=%d,len=%d)\n", uid, get_signature_name(uid), start,end, nlen, len);
#endif #endif
printf("signature for uid %x: (start=%x,end=%x, nlen=%d,len=%d)\n", uid, start,end, nlen, len);
} else { } else {
printf("*** got sample data, exiting\n"); printf("*** got sample data, exiting\n");
exit(0); exit(0);
...@@ -274,6 +276,7 @@ int accept_user_id(buffer *d){ ...@@ -274,6 +276,7 @@ int accept_user_id(buffer *d){
if(uid >= USER_ID_BASE) { if(uid >= USER_ID_BASE) {
advance32(d); advance32(d);
printf("uid = %x ", uid); printf("uid = %x ", uid);
push(d, uid);
return TRUE; return TRUE;
} else { } else {
return FALSE; return FALSE;
...@@ -355,7 +358,7 @@ int accept_array_decl(buffer *d){ ...@@ -355,7 +358,7 @@ int accept_array_decl(buffer *d){
if(tid == ARRAY_DECL) { if(tid == ARRAY_DECL) {
advance32(d); advance32(d);
unsigned int nidx = get32(d); unsigned int nidx = get32(d);
printf("%d dim array: ", nidx); printf("%d dim array", nidx);
int i; int i;
unsigned int numVar=0; unsigned int numVar=0;
unsigned int size=1; unsigned int size=1;
...@@ -363,16 +366,15 @@ int accept_array_decl(buffer *d){ ...@@ -363,16 +366,15 @@ int accept_array_decl(buffer *d){
unsigned int idx = get32(d); unsigned int idx = get32(d);
if(idx == 0) { if(idx == 0) {
numVar++; numVar++;
printf("variable index (numVar=%d), ",numVar); printf("[_] ");
} else { } else {
printf("fixed index: %d, ", idx); printf("[%d] ", idx);
size*=idx; size*=idx;
} }
printf("\n");
} }
printf(" of ");
unsigned int et=accept_type(d); unsigned int et=accept_type(d);
printf("array element type: %x\n", et); //pop(d);
pop(d);
//push(d,tid); //push(d,tid);
return TRUE; return TRUE;
} else { } else {
...@@ -404,7 +406,7 @@ int accept_struct_decl(buffer *d){ ...@@ -404,7 +406,7 @@ int accept_struct_decl(buffer *d){
int accept_field(buffer *d){ int accept_field(buffer *d){
printf("field "); printf("field ");
accept_string(d); accept_string(d);
// ignore, for now pop(d); // ignore, for now
printf(" : "); printf(" : ");
accept_type(d); accept_type(d);
printf("\n"); printf("\n");
...@@ -635,7 +637,7 @@ int main() { ...@@ -635,7 +637,7 @@ int main() {
} }
test_read(&buf); test_read(&buf);
do{ do{
printf("trying to read another packet\n"); printf("------------\n");
} while(more(&buf) && do_parse(&buf)); } while(more(&buf) && do_parse(&buf));
printf("done\n"); printf("done\n");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment