new type cw_type_ipaddress

FossilOrigin-Name: 9d8ad0bb712a80f52f4be5addec28710e0d0a323992621ee7affef86b9ff2166
This commit is contained in:
7u83@mail.ru 2018-03-21 17:50:07 +00:00
parent 8dd91ab6af
commit 95a253f470
6 changed files with 23 additions and 9 deletions

View File

@ -298,6 +298,7 @@
<File Name="src/cw/cw_dbg_set_level_from_str.c"/> <File Name="src/cw/cw_dbg_set_level_from_str.c"/>
<File Name="src/cw/ansi_colors.h"/> <File Name="src/cw/ansi_colors.h"/>
<File Name="src/cw/cw_clock_lap.c"/> <File Name="src/cw/cw_clock_lap.c"/>
<File Name="src/cw/cw_type_ipaddress.c"/>
</VirtualDirectory> </VirtualDirectory>
</VirtualDirectory> </VirtualDirectory>
<Description/> <Description/>
@ -320,7 +321,7 @@
</Compiler> </Compiler>
<Linker Options="" Required="yes"/> <Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/> <ResourceCompiler Options="" Required="no"/>
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="-dall" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/> <General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/ac/actube" CommandArguments="-dall" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/ac/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;"> <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[LD_LIBRARY_PATH=../../lib]]> <![CDATA[LD_LIBRARY_PATH=../../lib]]>
</Environment> </Environment>

View File

@ -224,13 +224,17 @@ int main (int argc, char *argv[])
cw_ktv_read_file(file,global_cfg,types_tree); cw_ktv_read_file(file,global_cfg,types_tree);
fclose(file); fclose(file);
cw_dbg_ktv_dump(global_cfg,DBG_INFO,NULL,"CFG:",NULL);
actube_global_cfg = global_cfg; 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_set_mod_path("../../lib/actube");
//cw_mod_load("capwap"); //cw_mod_load("capwap");

View File

@ -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_create_from_cfgstr(const char * s);
extern uint8_t * bstr_replace( bstr_t * dst, uint8_t * bstr); 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. * 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. * 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 *@defgroup BSTRConstants Constants

View File

@ -25,6 +25,9 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "bstr.h"
/** /**
* Creates a bstr_t string. * Creates a bstr_t string.
* @param data source data to create the string from * @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 * The bstr_t string returned is allocated by malloc. So remember to free
* this resource if you don't need it anymore. * 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)); uint8_t * str = malloc(1+len*sizeof(uint8_t));
if (!str) if (!str)
@ -43,3 +46,4 @@ uint8_t * bstr_create(uint8_t *data, uint8_t len)
memcpy(str+1,data,len); memcpy(str+1,data,len);
return str; return str;
} }

View File

@ -5,5 +5,6 @@ const cw_Type_t * cw_ktv_std_types[] = {
CW_TYPE_WORD, CW_TYPE_WORD,
CW_TYPE_DWORD, CW_TYPE_DWORD,
CW_TYPE_BSTR16, CW_TYPE_BSTR16,
CW_TYPE_IPADDRESS,
NULL NULL
}; };

View File

@ -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_word;
extern const struct cw_Type cw_type_dword; extern const struct cw_Type cw_type_dword;
extern const struct cw_Type cw_type_bstr16; 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_BYTE (&cw_type_byte)
#define CW_TYPE_WORD (&cw_type_word) #define CW_TYPE_WORD (&cw_type_word)
#define CW_TYPE_DWORD (&cw_type_dword) #define CW_TYPE_DWORD (&cw_type_dword)
#define CW_TYPE_BSTR16 (&cw_type_bstr16) #define CW_TYPE_BSTR16 (&cw_type_bstr16)
#define CW_TYPE_IPADDRESS (&cw_type_ipaddress)
/* /*
void cw_kvstore_mavl_delete(const void *data); void cw_kvstore_mavl_delete(const void *data);