diff options
author | FreeArtMan <dos21h@gmail.com> | 2019-05-21 22:21:21 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2019-05-21 22:21:21 +0100 |
commit | a22163cbe74e267bbe307c39c815dbb781acc83a (patch) | |
tree | 66eab8f1c8d1f4f46aaa65e6d93b7458727bce2f /netbytes.c | |
parent | 385f3ef50cb142bb860281230394df7a9e6b34b5 (diff) | |
download | netbytes-master.tar.gz netbytes-master.zip |
Diffstat (limited to 'netbytes.c')
-rw-r--r-- | netbytes.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -690,6 +690,7 @@ int nb_type( netbyte_store *store, int count, __NBT_TYPED **type ) //nbt = (__NBT_TYPED)store->types[count].type; //warnign? who cares //*type = nbt; + #warning "Looks like real error" *type = store->types[count].type; return 0; } @@ -762,6 +763,38 @@ int nb_fread( netbyte_store *store, int fd) return 0; } + +/* +Return: + 1 - looks like data are netbyte buffer + 0 - data isnot netbyte buffer +*/ +int nb_check_buf(uint8_t *data, int len, int *detected_size) +{ + __NBT_SIZE size; + if (len < sizeof(__NBT_SIZE)) + { + printf("if (len > sizeof(__NBT_SIZE))\n"); + return 0; + } + + memcpy(&size, data, sizeof(__NBT_SIZE)); + + if (len<size) + { + printf("if (len<size)\n"); + return 0; + } + + //amount of data that are netbyte in buffer + *detected_size = size; + + return 1; + //TODO find start byte for data in netbyte buffer + +} + + int nb_print(netbyte_store *store) { int i; |