test_sig_parser.c 721 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* labcomm_sig_parser.c:
 * a main program for the example labcomm signatures parser
 */

#include <stdio.h>

#include "labcomm_sig_parser.h"

#undef DEBUG_READ

#define BUF_SIZE 1024
#define STACK_SIZE 16

void test_read(buffer *buf) {
	int r = read_file(stdin, buf);
#ifdef DEBUG_READ
	printf("read %d bytes:\n\n", r);
	int i;
	for(i=0; i<r; i++) {
		printf("%x ", buf->c[i]);
		if(i%8 == 7) printf("\n");
	}
	printf("\n");
#endif
}
int main() {
	buffer buf;

	if( init_buffer(&buf, BUF_SIZE, STACK_SIZE) ) {
		printf("failed to init buffer\n");
		exit(1);
	}
	test_read(&buf);
	do{
		printf("--------------------------------------------- new packet: \n");
	} while(more(&buf) && do_parse(&buf)); 
	printf("EOF\n");
}