summaryrefslogtreecommitdiffstats
path: root/netbytes.h
diff options
context:
space:
mode:
Diffstat (limited to 'netbytes.h')
-rw-r--r--netbytes.h64
1 files changed, 36 insertions, 28 deletions
diff --git a/netbytes.h b/netbytes.h
index e4937fb..8b332b5 100644
--- a/netbytes.h
+++ b/netbytes.h
@@ -12,20 +12,20 @@
#define NBT_NONE 0x00 /* maybe not yet prepared type */
#define NBT_U8 0x01 /* single unsigned 8 bits */
#define NBT_U8ARRAY 0x02 /* u8 array */
-#define NBT_U16 0x03 /**/
-#define NBT_U16ARRAY 0x04 /**/
-#define NBT_U32 0x05 /**/
-#define NBT_U32ARRAY 0x06 /**/
-#define NBT_U64 0x07 /**/
-#define NBT_U64ARRAY 0x08 /**/
-#define NBT_I8 0x09 /**/
-#define NBT_I8ARRAY 0x0A /**/
-#define NBT_I16 0x0B /**/
-#define NBT_I16ARRAY 0x0C /**/
-#define NBT_I32 0x0D /**/
-#define NBT_I32ARRAY 0x0E /**/
-#define NBT_I64 0x0F /**/
-#define NBT_I64ARRAY 0x10 /**/
+#define NBT_U16 0x03 /* unsigned 16 bit */
+#define NBT_U16ARRAY 0x04 /* u16 array */
+#define NBT_U32 0x05 /* unsigned 32 bit */
+#define NBT_U32ARRAY 0x06 /* u32 array */
+#define NBT_U64 0x07 /* unsigned 64 bit */
+#define NBT_U64ARRAY 0x08 /* u64 array */
+#define NBT_I8 0x09 /* signed 8 bits */
+#define NBT_I8ARRAY 0x0A /* i8 array */
+#define NBT_I16 0x0B /* signed 16bits */
+#define NBT_I16ARRAY 0x0C /* i16 array */
+#define NBT_I32 0x0D /* signed 32 bits */
+#define NBT_I32ARRAY 0x0E /* i32 array */
+#define NBT_I64 0x0F /* signed 64 bits */
+#define NBT_I64ARRAY 0x10 /* i64 array */
#define NBT_F16 0x11 /**/
#define NBT_F32 0x12 /**/
#define NBT_F64 0x13 /**/
@@ -47,7 +47,7 @@
//creating netbyte structure
typedef struct __nb_type {
- __NBT_TYPED type;
+ __NBT_TYPED type;
uint8_t *nb_val;
} __nb_type;
@@ -75,14 +75,14 @@ typedef struct nb_u8arr
/*-----------------*/
typedef struct nb_u16
{
- __NBT_TYPED type;
+ __NBT_TYPED type;
uint16_t val;
} nb_u16;
typedef struct nb_u16arr
{
- __NBT_TYPED type;
- __NBT_U16ARR_LEN len;
+ __NBT_TYPED type;
+ __NBT_U16ARR_LEN len;
uint16_t *val;
} nb_u16arr;
@@ -90,14 +90,14 @@ typedef struct nb_u16arr
/*-----------------*/
typedef struct nb_u32
{
- __NBT_TYPED type;
+ __NBT_TYPED type;
uint32_t val;
} nb_u32;
typedef struct nb_u32arr
{
- __NBT_TYPED type;
- __NBT_U32ARR_LEN len;
+ __NBT_TYPED type;
+ __NBT_U32ARR_LEN len;
uint32_t *val;
} nb_u32arr;
@@ -105,26 +105,26 @@ typedef struct nb_u32arr
/*------------------*/
typedef struct nb_u64
{
- __NBT_TYPED type;
+ __NBT_TYPED type;
uint64_t val;
} nb_u64;
typedef struct nb_u64arr
{
- __NBT_TYPED type;
- __NBT_U64ARR_LEN len;
+ __NBT_TYPED type;
+ __NBT_U64ARR_LEN len;
uint64_t *val;
} nb_u64arr;
//loading/parsing netbyte structure
typedef struct netbyte_load
{
- __NBT_SIZE size;
+ __NBT_SIZE size;
uint8_t *buf;
} netbyte_load;
-int nb_u8_create( nb_u8 *s, uint8_t val );
-int nb_u8arr_create( nb_u8arr *s, __NBT_U8ARR_LEN len, uint8_t *val );
+int nb_u8_create( nb_u8 *s, uint8_t val );
+int nb_u8arr_create( nb_u8arr *s, __NBT_U8ARR_LEN len, uint8_t *val );
int nb_u16_create( nb_u16 *s, uint16_t val );
int nb_u16arr_create( nb_u16arr *s, __NBT_U16ARR_LEN len, uint16_t *val );
int nb_u32_create( nb_u32 *s, uint32_t val );
@@ -133,7 +133,6 @@ int nb_u64_create( nb_u64 *s, uint64_t val );
int nb_u64arr_create( nb_u64arr *s, __NBT_U64ARR_LEN len, uint64_t *val );
int nb_init( netbyte_store *store );
-
int nb_add_u8( netbyte_store *store, nb_u8 *u8 );
int nb_add_u8arr( netbyte_store *store, nb_u8arr *u8arr );
int nb_add_u16( netbyte_store *store, nb_u16 *u16 );
@@ -142,7 +141,10 @@ int nb_add_u32( netbyte_store *store, nb_u32 *u32 );
int nb_add_u32arr( netbyte_store *store, nb_u32arr *u32arr );
int nb_add_u64( netbyte_store *store, nb_u64 *u64 );
int nb_add_u64arr( netbyte_store *store, nb_u64arr *u64arr );
+
uint8_t *nb_create( netbyte_store *store );
+int nb_free(netbyte_store *store);
+
int nb_load( netbyte_store *store, uint8_t *data );
int nb_count( netbyte_store *store );
@@ -150,4 +152,10 @@ int nb_type( netbyte_store *store, int count, __NBT_TYPED **type );
int nb_val( netbyte_store *store, int count, uint8_t **val );
int nb_fread( netbyte_store *store, int fd);
+//print all all values in netbyte string
+int nb_print(netbyte_store *store);
+
+//check if netbyte matches particular format
+int nb_match(netbyte_store *store, char *frmt);
+
#endif \ No newline at end of file