From 95a253f470b96308a1cad1cec625b9ef6209a449 Mon Sep 17 00:00:00 2001
From: "7u83@mail.ru" <7u83@mail.ru@noemail.net>
Date: Wed, 21 Mar 2018 17:50:07 +0000
Subject: [PATCH] new type cw_type_ipaddress
FossilOrigin-Name: 9d8ad0bb712a80f52f4be5addec28710e0d0a323992621ee7affef86b9ff2166
---
libcw.project | 3 ++-
src/ac/ac_main.c | 14 ++++++++++----
src/cw/bstr.h | 6 +++---
src/cw/bstr_create.c | 6 +++++-
src/cw/cw_ktv_std_types.c | 1 +
src/cw/ktv.h | 2 ++
6 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/libcw.project b/libcw.project
index 3019eb5d..abe48ee1 100644
--- a/libcw.project
+++ b/libcw.project
@@ -298,6 +298,7 @@
+
@@ -320,7 +321,7 @@
-
+
diff --git a/src/ac/ac_main.c b/src/ac/ac_main.c
index 4211f678..50f739b1 100644
--- a/src/ac/ac_main.c
+++ b/src/ac/ac_main.c
@@ -224,13 +224,17 @@ int main (int argc, char *argv[])
cw_ktv_read_file(file,global_cfg,types_tree);
fclose(file);
-
- cw_dbg_ktv_dump(global_cfg,DBG_INFO,NULL,"CFG:",NULL);
+
+
actube_global_cfg = global_cfg;
+ cw_dbg_opt_level=0xffffffff;
+ cw_dbg(DBG_INFO,"Hello world\n");
-
-
+ cw_dbg_ktv_dump(global_cfg,DBG_INFO,NULL,"CFG:",NULL);
+ printf("Dumped\n");
+ exit(0);
+
@@ -255,6 +259,8 @@ int main (int argc, char *argv[])
// cw_mod_set_mod_path("../../lib/actube");
//cw_mod_load("capwap");
+
+
diff --git a/src/cw/bstr.h b/src/cw/bstr.h
index c45d7be6..5090ec83 100644
--- a/src/cw/bstr.h
+++ b/src/cw/bstr.h
@@ -49,7 +49,7 @@ typedef uint8_t* bstr_t;
*@}
*/
-extern uint8_t * bstr_create(uint8_t *data, uint8_t len);
+extern uint8_t * bstr_create(const uint8_t *data, uint8_t len);
extern uint8_t * bstr_create_from_cfgstr(const char * s);
extern uint8_t * bstr_replace( bstr_t * dst, uint8_t * bstr);
@@ -65,12 +65,12 @@ extern int bstr_to_str(char *dst, bstr_t str,char * def);
/**
* Return the data of a bstr_t string.
*/
-#define bstr_data(s) ((s)+1)
+#define bstr_data(s) (((uint8_t*)(s))+1)
/**
* Return the actual size in memory a bstr_t string needs.
*/
-#define bstr_size(len) (len+1)
+#define bstr_size(len) ((len)+1)
/**
*@defgroup BSTRConstants Constants
diff --git a/src/cw/bstr_create.c b/src/cw/bstr_create.c
index 03c8c5ad..5599bb56 100644
--- a/src/cw/bstr_create.c
+++ b/src/cw/bstr_create.c
@@ -25,6 +25,9 @@
#include
#include
+
+#include "bstr.h"
+
/**
* Creates a bstr_t string.
* @param data source data to create the string from
@@ -34,7 +37,7 @@
* The bstr_t string returned is allocated by malloc. So remember to free
* this resource if you don't need it anymore.
*/
-uint8_t * bstr_create(uint8_t *data, uint8_t len)
+uint8_t * bstr_create(const uint8_t *data, uint8_t len)
{
uint8_t * str = malloc(1+len*sizeof(uint8_t));
if (!str)
@@ -43,3 +46,4 @@ uint8_t * bstr_create(uint8_t *data, uint8_t len)
memcpy(str+1,data,len);
return str;
}
+
diff --git a/src/cw/cw_ktv_std_types.c b/src/cw/cw_ktv_std_types.c
index db7265cb..c2e75f26 100644
--- a/src/cw/cw_ktv_std_types.c
+++ b/src/cw/cw_ktv_std_types.c
@@ -5,5 +5,6 @@ const cw_Type_t * cw_ktv_std_types[] = {
CW_TYPE_WORD,
CW_TYPE_DWORD,
CW_TYPE_BSTR16,
+ CW_TYPE_IPADDRESS,
NULL
};
diff --git a/src/cw/ktv.h b/src/cw/ktv.h
index d15f820e..d0230238 100644
--- a/src/cw/ktv.h
+++ b/src/cw/ktv.h
@@ -76,11 +76,13 @@ extern const struct cw_Type cw_type_byte;
extern const struct cw_Type cw_type_word;
extern const struct cw_Type cw_type_dword;
extern const struct cw_Type cw_type_bstr16;
+extern const struct cw_Type cw_type_ipaddress;
#define CW_TYPE_BYTE (&cw_type_byte)
#define CW_TYPE_WORD (&cw_type_word)
#define CW_TYPE_DWORD (&cw_type_dword)
#define CW_TYPE_BSTR16 (&cw_type_bstr16)
+#define CW_TYPE_IPADDRESS (&cw_type_ipaddress)
/*
void cw_kvstore_mavl_delete(const void *data);