Commit a733b92f authored by Sven Robertz's avatar Sven Robertz
Browse files

cleanup, but still not supporting skipping of data (at least for varsize arrays)

parent 65d8c373
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#define DEBUG #define DEBUG
#undef DEBUG_STACK #undef DEBUG_STACK
#undef DEBUG_READ
#define EXIT_WHEN_RECEIVING_DATA //arrays (at least varsize not working)
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
...@@ -236,7 +239,7 @@ int do_parse(buffer *d) { ...@@ -236,7 +239,7 @@ int do_parse(buffer *d) {
return TRUE; return TRUE;
} else if (type == SAMPLE_DECL) { } else if (type == SAMPLE_DECL) {
advance32(d); advance32(d);
printf("sample "); printf("sample_decl ");
accept_user_id(d); accept_user_id(d);
unsigned int nstart = d->idx; unsigned int nstart = d->idx;
unsigned int uid = pop(d); unsigned int uid = pop(d);
...@@ -245,29 +248,33 @@ int do_parse(buffer *d) { ...@@ -245,29 +248,33 @@ int do_parse(buffer *d) {
unsigned int start = d->idx; unsigned int start = d->idx;
unsigned int nlen = pop(d); unsigned int nlen = pop(d);
accept_type(d); accept_type(d);
printf(" : "); //printf(" : ");
//unsigned int dt = pop(d); //unsigned int dt = pop(d);
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[uid-USER_ID_BASE], &d->c[start], len);
} else { } else {
error("sig longer than max length (this ought to be dynamic...)"); error("sig longer than max length (this ought to be dynamic...)");
} }
if(nlen < MAX_NAME_LEN) { // reserve space for terminating NULL
if(nlen < MAX_NAME_LEN) { // leave 1 byte for terminating NULL
signatures_name[uid-USER_ID_BASE][0] = nlen;
memcpy(signatures_name[uid-USER_ID_BASE], &d->c[nstart+3], nlen);
signatures_name[uid-USER_ID_BASE][nlen+1]=0; signatures_name[uid-USER_ID_BASE][nlen+1]=0;
memcpy(signatures[uid-USER_ID_BASE], &d->c[start], len);
} else { } else {
error("sig name longer than max length (this ought to be dynamic..."); error("sig name longer than max length (this ought to be dynamic...");
} }
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
printf("signature for uid %x: (start=%x,end=%x, nlen=%d,len=%d)\n", uid, start,end, nlen, len);
} else { } else {
#ifdef EXIT_WHEN_RECEIVING_DATA
printf("*** got sample data, exiting\n"); printf("*** got sample data, exiting\n");
exit(0); exit(0);
#else
accept_sample_data(d);
#endif
} }
} }
...@@ -396,7 +403,6 @@ int accept_struct_decl(buffer *d){ ...@@ -396,7 +403,6 @@ int accept_struct_decl(buffer *d){
accept_field(d); accept_field(d);
} }
// push(d,tid); // push(d,tid);
printf("----\n");
return TRUE; return TRUE;
} else { } else {
printf("accept_struct_decl: type=%x, should not happen\n",tid); printf("accept_struct_decl: type=%x, should not happen\n",tid);
...@@ -620,6 +626,7 @@ int read_file(FILE *f, buffer *b) { ...@@ -620,6 +626,7 @@ int read_file(FILE *f, buffer *b) {
void test_read(buffer *buf) { void test_read(buffer *buf) {
int r = read_file(stdin, buf); int r = read_file(stdin, buf);
#ifdef DEBUG_READ
printf("read %d bytes:\n\n", r); printf("read %d bytes:\n\n", r);
int i; int i;
for(i=0; i<r; i++) { for(i=0; i<r; i++) {
...@@ -627,6 +634,7 @@ void test_read(buffer *buf) { ...@@ -627,6 +634,7 @@ void test_read(buffer *buf) {
if(i%8 == 7) printf("\n"); if(i%8 == 7) printf("\n");
} }
printf("\n"); printf("\n");
#endif
} }
int main() { int main() {
buffer buf; buffer buf;
......
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