diff options
author | FreeArtMan <=> | 2015-11-07 18:18:59 +0000 |
---|---|---|
committer | FreeArtMan <=> | 2015-11-07 18:18:59 +0000 |
commit | 3c89841f31cd7fc6cb35c129a9135c5e974a7649 (patch) | |
tree | 4f0eb8fd7a90c8f194b4f8580e8c4f512dfa13e2 /test/test_multiple_read.c | |
parent | 9514d70e98fa7f8fa26f991586169b9da09e7ea6 (diff) | |
download | netbytes-3c89841f31cd7fc6cb35c129a9135c5e974a7649.tar.gz netbytes-3c89841f31cd7fc6cb35c129a9135c5e974a7649.zip |
example/test source
Diffstat (limited to 'test/test_multiple_read.c')
-rw-r--r-- | test/test_multiple_read.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/test/test_multiple_read.c b/test/test_multiple_read.c new file mode 100644 index 0000000..3bec7dc --- /dev/null +++ b/test/test_multiple_read.c @@ -0,0 +1,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; +}
\ No newline at end of file |