renamed a lot of cw_format_* to format_*

FossilOrigin-Name: 23ddf0840bc6910dc3ddf4f763ff9976441573173d8e669cc02cbc0520f12f00
This commit is contained in:
7u83@mail.ru 2016-03-12 08:28:35 +00:00
parent 10efce8ee2
commit 1dbb599802
13 changed files with 36 additions and 50 deletions

View File

@ -22,3 +22,4 @@ CC=clang
COMPDEFS=-DWITH_CW_LOG
COMPDEFS+=-DWITH_CW_LOG_DEBUG

View File

@ -2,7 +2,7 @@ include ../Config.mak
#
SSL_LIBRARY=GNUTLS
#WITH_OPENSSL=1
CFLAGS += -I/usr/include/libnl3

View File

@ -24,7 +24,7 @@ uint8_t * bstr16_create_from_str(const char *s)
msize++;
uint8_t * mem = malloc(2+msize);
*((uint16_t*)mem)=msize;
cw_format_scan_hex_bytes(mem+2,s+2,l);
format_scan_hex_bytes(mem+2,s+2,l);
return mem;
}

View File

@ -24,7 +24,7 @@ uint8_t * bstr_create_from_str(const char *s)
msize++;
uint8_t * mem = malloc(1+msize);
*((uint8_t*)mem)=msize;
cw_format_scan_hex_bytes(mem+2,s+2,l);
format_scan_hex_bytes(mem+2,s+2,l);
return mem;
}

View File

@ -233,7 +233,7 @@ int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int l
s+=sprintf(s," Flgs:");
s+=cw_format_hdr_flags(s,packet);
s+=format_hdr_flags(s,packet);
if (len<8)
goto abort;
@ -252,7 +252,7 @@ int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int l
plen=10;
s+=sprintf(s," R-MAC:");
s+=cw_format_mac(s,cw_get_hdr_rmac_data(packet),plen);
s+=format_mac(s,cw_get_hdr_rmac_data(packet),plen);
if (rmac_len>10){
s+=sprintf(s," ... (len=%d)",rmac_len);
}

View File

@ -194,6 +194,11 @@ void cw_dbg_version_subelem(int level,const char*context,int subtype,bstrv_t vst
#define cw_dbg_set_level(level,on)\
(on ? cw_dbg_opt_level |= (1<<(level)) : (cw_dbg_opt_level &= (-1)^(1<<(level))))
/**
* Check if a specific debug level is set.
* @param level Level to check
* @return 0 if leveln is not set, otherwise level is set
*/
#define cw_dbg_is_level(level)\
(cw_dbg_opt_level & (1<<level))

View File

@ -1,7 +1,7 @@
/*
This file is part of libcapwap.
This file is part of actube.
libcapwap is free software: you can redistribute it and/or modify
actube is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@ -51,6 +51,7 @@ struct cw_strlist_elem cw_dbg_strings[] = {
{ DBG_ELEM_ERR, "elem_err" },
{ DBG_DTLS, "dtls" },
{ DBG_DTLS_BIO, "dtls_bio" },
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
{ DBG_WARN, "warn" },
{ DBG_MOD,"mod"},
@ -96,14 +97,4 @@ struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
};
*/
/*
int cw_log_str2dbglevel(const char * str)
{
int i;
for (i=0; cw_dbg_cfgstrs[i].name; i++) {
if (!strcmp(str,cw_dbg_cfgstrs[i].name))
return cw_dbg_cfgstrs[i].level;
}
return 0;
}
*/

View File

@ -40,7 +40,7 @@
* where x is the number of characters. A formatted hex byte needs (typically 2).
*
*/
int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
int format_hex_bytes(char *dst, const char *format, const char *delim,
const uint8_t * src, int len)
{
char *d = dst;
@ -68,7 +68,7 @@ int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
* @return 0 if all was ok \n 1 if an error has occured.
*/
int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len)
int format_scan_hex_bytes(uint8_t *dst,const char *s, int len)
{
int rc ;
int err=0;

View File

@ -18,19 +18,19 @@
/**
*@file
*@brief prototypes for format-functions
*@defgroup FormatFunctions FORMAT Functions
*@defgroup FORMAT FORMAT
*@{
*/
#ifndef __CW_FORMAT_H
#define __CW_FORMAT_H
#ifndef __FORMAT_H
#define __FORMAT_H
#include "cw.h"
extern int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
extern int format_hex_bytes(char *dst, const char *format, const char *delim,
const uint8_t * src, int len);
extern int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
extern int format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
@ -44,39 +44,28 @@ extern int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
* Make sure, the destination buffer can hold at least len * 2 characters + the trailing
* zero for strings.
*/
#define cw_format_hexl(dst,bytes,len)\
cw_format_hex_bytes(dst,"%02x","",bytes,len)
#define format_hexl(dst,bytes,len)\
format_hex_bytes(dst,"%02x","",bytes,len)
/**
* Format bytes as hex string. Same as #cw_format_hexl, but
* Format bytes as hex string. Same as #format_hexl, but
* hexadecimal letters are upper-case.
*/
#define cw_format_hexu(dst,bytes,len)\
cw_format_hex_bytes(dst,"%02X","",bytes,len)
#define format_hexu(dst,bytes,len)\
format_hex_bytes(dst,"%02X","",bytes,len)
/**
* Alias for #cw_format_hexl.
* Alias for #format_hexl.
*/
#define cw_format_hex cw_format_hexl
#define format_hex format_hexl
/**
* Format MAC Address.
*/
#define cw_format_mac(dst,src,len)\
cw_format_hex_bytes(dst,"%02x",":",src,len)
#define format_mac(dst,src,len)\
format_hex_bytes(dst,"%02x",":",src,len)
/*#define cw_format_hdr_flags(s,th) \
sprintf(s,"(T=%d,F=%d,L=%d,W=%d,M=%d,K=%d)",\
cw_get_hdr_flag_t(packet),\
cw_get_hdr_flag_f(packet),\
cw_get_hdr_flag_l(packet),\
cw_get_hdr_flag_w(packet),\
cw_get_hdr_flag_m(packet),\
cw_get_hdr_flag_k(packet)\
);
*/
static inline int cw_format_hdr_flags(char *dst,uint8_t *th)
static inline int format_hdr_flags(char *dst,uint8_t *th)
{
char * s = dst;
s+=sprintf(s,"%s", "(");

View File

@ -22,7 +22,7 @@ static int to_str(void *item,char *dst)
d += sprintf(d, "%.*s", bstr16_len(i->data), bstr16_data(i->data));
} else {
d += sprintf(d, ".x");
d += cw_format_hex(d, bstr16_data(i->data), bstr16_len(i->data));
d += format_hex(d, bstr16_data(i->data), bstr16_len(i->data));
}
return d-dst;
}

View File

@ -40,7 +40,7 @@ static int to_str(void *item,char *dst)
bstrv_data(i->data));
} else {
d += sprintf(d, ".x");
d += cw_format_hex(d, bstrv_data(i->data), bstrv_len(i->data));
d += format_hex(d, bstrv_data(i->data), bstrv_len(i->data));
}
return d-dst;

View File

@ -30,7 +30,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
bstrv_set_vendor_id(mem,vendor_id);
bstrv_set_len(mem,msize);
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
format_scan_hex_bytes(bstrv_data(mem),s+2,l);
return mem;
}

View File

@ -18,7 +18,7 @@ int setup_conf(struct conn * conn)
* base rmac */
char name[32];
strcpy(name,WTP_DEFAULT_NAME_PREFIX);
int l = cw_format_hexu(name+strlen(WTP_DEFAULT_NAME_PREFIX),
int l = format_hexu(name+strlen(WTP_DEFAULT_NAME_PREFIX),
bstr_data(conn->base_rmac),bstr_len(conn->base_rmac));
name[l+strlen(WTP_DEFAULT_NAME_PREFIX)]=0;