This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

What does TFS() in tfs.h do?

0

Ok thank you. I was only familiar with #pragma once. However from your answer I conclude, that __TFS_H__ is not a requirement for using the syntax TFS(). I could use that without the guard. What I meant in my other point is, what is the logic behind 'TFS()`? Where is it declared?

asked 14 Apr '16, 02:48

mikethebo's gravatar image

mikethebo
21447
accept rate: 0%

converted 14 Apr '16, 12:14

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196


One Answer:

0

Fields with an integral data type can be given a value_string list, which maps values of that field to descriptive strings. Fields with a Boolean data type can be given a true_false_string list, which maps TRUE and FALSE to descriptive strings.

If we required C99, we could make a field in the header_field_info structure that was a union of value_string * and struct true_false_string * and have integral fields initialize the former member and Boolean fields initialize the latter member.

However, Wireshark doesn't require C99, and C90 doesn't handle initialization of a union very well - the initializer initializes the first element of the union, with no way to initialize other members.

So we just made the field a const void *, and have macros VALS() and TFS() that cast value_string * and struct true_false_string * to const void *, which are used in initializers.

VALS() and TFS() are macros, and are defined in epan/proto.h.

answered 14 Apr '16, 12:21

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

edited 14 Apr '16, 12:22

Oh man thank you. I was looking for this by doing multiple full text searches in the Windows Explorer. Obviously not very reliable. This almost has the dimension of RTFM, still thank you for you complete answer.

(22 Apr '16, 09:58) mikethebo