summaryrefslogtreecommitdiff
path: root/netbytes.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-06-04 00:17:22 +0100
committerFreeArtMan <dos21h@gmail.com>2017-06-04 00:17:22 +0100
commit18b2ebe3df26009ef6b2aeb0670a396e876fca25 (patch)
tree3b851d392330877513c460b03e87b4d0d52ef0fb /netbytes.h
parenta3c2eb86925cf35ef6b0fbb12249cee6a15060cb (diff)
downloadnetbytes-18b2ebe3df26009ef6b2aeb0670a396e876fca25.tar.gz
netbytes-18b2ebe3df26009ef6b2aeb0670a396e876fca25.zip
Added nb_match functionality
Diffstat (limited to 'netbytes.h')
-rw-r--r--netbytes.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/netbytes.h b/netbytes.h
index a73dcc6..3960142 100644
--- a/netbytes.h
+++ b/netbytes.h
@@ -124,6 +124,21 @@ typedef struct netbyte_load
uint8_t *buf;
} netbyte_load;
+typedef struct nb_tok
+{
+ int sign;
+ int type_size;
+ int len;
+ int arr;
+} nb_tok;
+
+typedef struct nb_tok_arr
+{
+ int size;
+ int len;
+ nb_tok *tok;
+} nb_tok_arr;
+
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 );
@@ -150,35 +165,27 @@ int nb_free(netbyte_store *store);
int nb_load( netbyte_store *store, uint8_t *data );
int nb_count( netbyte_store *store );
int nb_type( netbyte_store *store, int count, __NBT_TYPED **type );
-int nb_val( netbyte_store *store, int count, uint8_t **val );
+int nb_val( netbyte_store *store, int count, __nb_type **type );
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, int size);
+/*
+check if netbyte matches particular format
+-1 err
+1 not match
+0 match
+*/
+int nb_match(netbyte_store *store, nb_tok_arr *pattern);
#define SIGN_UNSIGNED 1
#define SIGN_SIGNED 2
-typedef struct nb_tok
-{
- int sign;
- int type_size;
- int len;
- int arr;
-} nb_tok;
-
-typedef struct nb_tok_arr
-{
- int size;
- int len;
- nb_tok *tok;
-} nb_tok_arr;
-
nb_tok_arr *nb_tok_create(int size);
int nb_tok_add(nb_tok_arr *arr, int sign, int type_size, int len, int farr);
void nb_tok_destroy(nb_tok_arr *arr);
+int nb_parse(char *str, nb_tok_arr *arr);
+
#endif \ No newline at end of file