32 if (fieldValue == NULL)
return;
34 int timeIsInMilliseconds = 0;
36 switch (fieldValue->
fType) {
38 printf(
"%u", fieldValue->
fByte);
42 printf(
"%d", (int8_t)(fieldValue->
fByte));
46 printf(
"%u", fieldValue->
fBytes2);
50 printf(
"%d", (int16_t)(fieldValue->
fBytes2));
55 printf(
"%u/%02u/%02u",
56 ((fieldValue->
fBytes2&0xFE00)>>9) + 1980,
57 (fieldValue->
fBytes2&0x01E0)>>5,
63 printf(
"%u", fieldValue->
fBytes4);
67 printf(
"%d", (int32_t)(fieldValue->
fBytes4));
72 u_int32_t v = fieldValue->
fBytes4;
73 printf(
"%u.%u.%u", (v>>24)&0xFF, (v>>16)&0xFF, (v>>8)&0xFF);
77 printf(
"%.*f", numFractionalDigits, fieldValue->
fFloat);
81 printf(
"%.*f", numFractionalDigits, fieldValue->
fDouble);
85 timeIsInMilliseconds = 1;
89 u_int64_t time = fieldValue->
fBytes8;
90 u_int64_t timeInSeconds;
91 unsigned milliseconds;
93 if (timeIsInMilliseconds) {
94 timeInSeconds = time/1000;
95 milliseconds = time%1000;
101 struct tm* convertedTime = gmtime((time_t*)&timeInSeconds);
102 if (convertedTime == NULL) {
103 fprintf(stderr,
"outputField(8-byte timestamp): gmtime(%llu) failed!\n", timeInSeconds);
106 printf(
"%u/%02u/%02u %02u:%02u:%02u",
107 convertedTime->tm_year + 1900, convertedTime->tm_mon + 1, convertedTime->tm_mday,
108 convertedTime->tm_hour, convertedTime->tm_min, convertedTime->tm_sec);
109 if (timeIsInMilliseconds) {
110 printf(
".%03u", milliseconds);
115 printf(
"%s", fieldValue->
fStr);
123 if (fieldValue == NULL)
return;
125 int booleanValue = 0;
127 switch (fieldValue->
fType) {
130 booleanValue = fieldValue->
fByte != 0;
135 booleanValue = fieldValue->
fBytes2 != 0;
140 booleanValue = fieldValue->
fBytes4 != 0;
148 printf(booleanValue ?
"True" :
"False");
154 if (fieldValue == NULL)
return;
158 switch (fieldValue->
fType) {
160 intValue = (u_int32_t)(fieldValue->
fByte);
164 intValue = (u_int32_t)(fieldValue->
fBytes2);
168 intValue = fieldValue->
fBytes4;;
178 if (interpretationTable == NULL)
return;
181 printf(
"%s", interpretationTable->
lookup(intValue));
void outputFieldInterpreted(char const *label, char const *interpretedLabel)
std::unordered_map< char const *, InterpretationTable * > fInterpretationTableMap
void outputField(char const *label, unsigned numFractionalDigits=0)
void outputFieldAsBoolean(char const *label)
char const * lookup(u_int32_t intValue)
FieldValue const * lookupFieldValue(char const *label)