forked from osmocom/wireshark
Convert all the other function-defining macros.
(Perhaps C2099 will finally deprecate old-style function definitions and allow you to declare parameters without names, just as C++ does, and compilers will - obviously - not warn about those parameters being unreferenced, obviating the need for __attribute((unused))__ and the like. And perhaps monkeys will fly out of....) Change-Id: Iff295c1854e66eb4f9e02cdd5761e0191d371365 Reviewed-on: https://code.wireshark.org/review/4018 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
746a265f99
commit
d853e92b75
30
epan/uat.h
30
epan/uat.h
|
@ -351,7 +351,7 @@ WS_DLL_PUBLIC
|
|||
CHK_STR_IS_DECL(isxdigit);
|
||||
|
||||
#define CHK_STR_IS_DEF(what) \
|
||||
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) { \
|
||||
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* UNUSED_PARAMETER(u2), const void* UNUSED_PARAMETER(u3), const char** err) { \
|
||||
guint i; for (i=0;i<len;i++) { \
|
||||
char c = strptr[i]; \
|
||||
if (! what((int)c)) { \
|
||||
|
@ -370,11 +370,11 @@ gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strpt
|
|||
* a simple c-string contained in (((rec_t*)rec)->(field_name))
|
||||
*/
|
||||
#define UAT_CSTRING_CB_DEF(basename,field_name,rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
char* new_buf = g_strndup(buf,len); \
|
||||
g_free((((rec_t*)rec)->field_name)); \
|
||||
(((rec_t*)rec)->field_name) = new_buf; } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
if (((rec_t*)rec)->field_name ) { \
|
||||
*out_ptr = (((rec_t*)rec)->field_name); \
|
||||
*out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
|
||||
|
@ -418,11 +418,11 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
* LSTRING MACROS
|
||||
*/
|
||||
#define UAT_LSTRING_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
char* new_val = uat_unesc(buf,len,&(((rec_t*)rec)->len_element)); \
|
||||
g_free((((rec_t*)rec)->ptr_element)); \
|
||||
(((rec_t*)rec)->ptr_element) = new_val; }\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
if (((rec_t*)rec)->ptr_element ) { \
|
||||
*out_ptr = uat_esc(((rec_t*)rec)->ptr_element, (((rec_t*)rec)->len_element)); \
|
||||
*out_len = (unsigned)strlen(*out_ptr); \
|
||||
|
@ -440,12 +440,12 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
* XXX: UNTESTED and probably BROKEN
|
||||
*/
|
||||
#define UAT_BUFFER_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
char* new_buf = len ? (char *)g_memdup(buf,len) : NULL; \
|
||||
g_free((((rec_t*)rec)->ptr_element)); \
|
||||
(((rec_t*)rec)->ptr_element) = new_buf; \
|
||||
(((rec_t*)rec)->len_element) = len; } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
*out_ptr = ((rec_t*)rec)->ptr_element ? (const char*)ep_memdup(((rec_t*)rec)->ptr_element,((rec_t*)rec)->len_element) : ""; \
|
||||
*out_len = ((rec_t*)rec)->len_element; }
|
||||
|
||||
|
@ -458,9 +458,9 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
* a decimal number contained in
|
||||
*/
|
||||
#define UAT_DEC_CB_DEF(basename,field_name,rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
((rec_t*)rec)->field_name = (guint)strtol(ep_strndup(buf,len),NULL,10); } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
*out_ptr = ep_strdup_printf("%d",((rec_t*)rec)->field_name); \
|
||||
*out_len = (unsigned)strlen(*out_ptr); }
|
||||
|
||||
|
@ -476,9 +476,9 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
* an hexadecimal number contained in
|
||||
*/
|
||||
#define UAT_HEX_CB_DEF(basename,field_name,rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
((rec_t*)rec)->field_name = (guint)strtol(ep_strndup(buf,len),NULL,16); } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
*out_ptr = ep_strdup_printf("%x",((rec_t*)rec)->field_name); \
|
||||
*out_len = (unsigned)strlen(*out_ptr); }
|
||||
|
||||
|
@ -534,7 +534,7 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
*/
|
||||
|
||||
#define UAT_PROTO_DEF(basename, field_name, dissector_field, name_field, rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
if (len) { \
|
||||
gchar *tmp = g_strndup(buf,len); \
|
||||
((rec_t*)rec)->name_field = g_ascii_strdown(tmp, -1); \
|
||||
|
@ -545,7 +545,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
|
|||
((rec_t*)rec)->dissector_field = find_dissector("data"); \
|
||||
((rec_t*)rec)->name_field = NULL; \
|
||||
} } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
if ( ((rec_t*)rec)->name_field ) { \
|
||||
*out_ptr = (((rec_t*)rec)->name_field); \
|
||||
*out_len = (unsigned)strlen(*out_ptr); \
|
||||
|
@ -561,11 +561,11 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
|
|||
*/
|
||||
|
||||
#define UAT_RANGE_CB_DEF(basename,field_name,rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2) {\
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* u2) {\
|
||||
char* rng = ep_strndup(buf,len);\
|
||||
range_convert_str(&(((rec_t*)rec)->field_name), rng,GPOINTER_TO_UINT(u2)); \
|
||||
} \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
if ( ((rec_t*)rec)->field_name ) { \
|
||||
*out_ptr = range_convert_range(((rec_t*)rec)->field_name); \
|
||||
*out_len = (unsigned)strlen(*out_ptr); \
|
||||
|
|
Loading…
Reference in New Issue