Reformatted

FossilOrigin-Name: 0ee8c4d6c81557eea2f8bd3ea9c1a3646591661180b0b175f8ba48e4e7a94d7b
This commit is contained in:
7u83@mail.ru 2018-02-23 08:06:22 +00:00
parent 2ab86e8fc6
commit e0f6aadace

View File

@ -17,7 +17,7 @@
*/
/**
*@file
*@brief prototypes for format-functions
*@brief Prototypes of cw_format-functions
*@defgroup FORMAT FORMAT
*@{
*/
@ -29,20 +29,21 @@
extern int format_hex_bytes(char *dst, const char *format, const char *delim,
const uint8_t * src, int len);
const uint8_t * src, int len);
static inline char * format_s_hex_bytes(char *dst, const char *format, const char *delim,
const uint8_t * src, int len){
format_hex_bytes(dst,format,delim,src,len);
static inline char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
const uint8_t * src, int len)
{
format_hex_bytes(dst, format, delim, src, len);
return dst;
}
#define format_bin2hex(src,len) (format_s_hex_bytes((char[(len)*2+1]){0},"%02X","",src,len))
#define format_bin2hex(src,len) (format_s_hex_bytes((char[(len) * 2 + 1]) {0}, "%02X", "", src, len))
extern int 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);
/**
@ -72,22 +73,22 @@ extern int format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
/**
* Format MAC Address.
*/
*/
#define format_mac(dst,src,len)\
format_hex_bytes(dst,"%02x",":",src,len)
static inline int 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", "(");
s+=sprintf(s,"%s", cw_get_hdr_flag_t(th) ? "T":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_f(th) ? "F":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_l(th) ? "L":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_w(th) ? "W":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_m(th) ? "M":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_k(th) ? "K":"");
s+=sprintf(s,"%s", ")");
return s-dst;
char *s = dst;
s += sprintf(s, "%s", "(");
s += sprintf(s, "%s", cw_get_hdr_flag_t(th) ? "T" : "");
s += sprintf(s, "%s", cw_get_hdr_flag_f(th) ? "F" : "");
s += sprintf(s, "%s", cw_get_hdr_flag_l(th) ? "L" : "");
s += sprintf(s, "%s", cw_get_hdr_flag_w(th) ? "W" : "");
s += sprintf(s, "%s", cw_get_hdr_flag_m(th) ? "M" : "");
s += sprintf(s, "%s", cw_get_hdr_flag_k(th) ? "K" : "");
s += sprintf(s, "%s", ")");
return s - dst;
}