blob: 3bec7dc36091d8de08497409a871062f1509dd6e (
plain) (
blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include <stdio.h>
#include <stdlib.h>
#include <netbytes.h>
void pr_u8( nb_u8 *u8 )
{
if ( !u8 )
{
printf("\tu8: NULL\n");
return;
} else
{
printf("\tu8: t=0x%x v=0x%x\n", u8->type, u8->val );
}
}
void pr_u8arr( nb_u8arr *u8arr )
{
if (!u8arr)
{
printf("\tu8arr: NULL\n");
return ;
} else
{
printf("\tu8arr: t=0x%x l=0x%x v=0x%x\n",
u8arr->type, u8arr->len, u8arr->val );
}
}
void pr_store( netbyte_store *nb )
{
int i;
if (!nb)
{
printf("nb: NULL\n");
return;
}
printf("nb: s=0x%x c=0x%x\n", nb->size, nb->count );
for (i=0;i<nb->count;i++)
{
//printf("\t[%x] -> ",i );
if ( nb->types[i].type == NBT_U8 )
{
pr_u8( (nb_u8 *)nb->types[i].nb_val );
} else if ( nb->types[i].type == NBT_U8ARRAY )
{
pr_u8arr( (nb_u8arr *)nb->types[i].nb_val );
} else
{
printf("Unknown\n");
}
}
}
int main()
{
int er;
uint8_t *res;
FILE *f;
int i=0;
netbyte_store nb;
printf("Start test\n");
nb_init( &nb );
f = fopen("test_many.nb","r");
while (nb_fread( &nb, fileno(f) ) == 0)
{
printf("ITER %d: ", i );
pr_store( &nb );
i += 1;
}
fclose( f );
printf("End test\n");
return 0;
}
|