diff --git a/data/M3-2017-01-31.csv b/data/M3-2017-01-31.csv index cb8850b..e2af9fb 100644 --- a/data/M3-2017-01-31.csv +++ b/data/M3-2017-01-31.csv @@ -60,6 +60,7 @@ M3.7,2017-01-31,v2.00, NET, 0.001595, M3.7,2017-01-31,v2.00, EC2, 0.001367, M3.7,2017-01-31,v2.00, -- NUMBER --, 0.001139, M3.7,2017-01-31,v2.00, _TCP, 0.001139, +M3.7,2017-01-31,v2.00, \172\016, 0.001137, M3.8,2017-01-31,v2.00, , 0.099502, M3.9,2017-01-31,v2.00, , 0.283371, M3.10,2017-01-31,v2.00,0, 0.042701, diff --git a/data/M3Data-test-ref.txt b/data/M3Data-test-ref.txt index c5e4c81..1e1cddf 100644 --- a/data/M3Data-test-ref.txt +++ b/data/M3Data-test-ref.txt @@ -67,7 +67,8 @@ ["NET", [0.159500, 0.159500]], ["EC2", [0.136700, 0.136700]], ["-- NUMBER --", [0.113900, 0.113900]], -["_TCP", [0.113900, 0.113900]]], +["_TCP", [0.113900, 0.113900]], +["\\172\\016", [0.113700, 0.000000]]], "M38" : [9.950200, 8.750200], "M39" : [28.337100, 31.234500], "M3_10" : [ diff --git a/lib/ithipublisher.cpp b/lib/ithipublisher.cpp index 7a5b068..02693cb 100644 --- a/lib/ithipublisher.cpp +++ b/lib/ithipublisher.cpp @@ -590,6 +590,30 @@ bool ithipublisher::PrintVector(FILE * F, std::vector * vx, double mult) return ret; } +/* The ITHI tools will sometimes generate "escaped" names, e.g. \172\016. They must be escaped to not violate JSON syntax */ +char const* double_whacks(char const* input_name, char* text, size_t text_size) +{ + int i = 0; + int j = 0; + + while (input_name[i] != 0 && j < text_size - 2) { + if (input_name[i] == '\\') { + text[j] = '\\'; + j++; + text[j] = '\\'; + j++; + } + else + { + text[j] = input_name[i]; + j++; + } + i++; + } + text[j] = 0; + return text; +} + bool ithipublisher::PrintNameOrNumberVectorMetric(FILE * F, char const * sub_met_name, char const * metric_name, double mult, bool is_number) { std::vector mvec; @@ -597,6 +621,7 @@ bool ithipublisher::PrintNameOrNumberVectorMetric(FILE * F, char const * sub_met bool ret = GetNameOrNumberList(sub_met_name, &name_list, is_number); bool need_comma = true; bool check_arpa = strcmp(sub_met_name, "M3.3.2") == 0; + char text_buffer[512]; ret &= fprintf(F, "\"%s\" : [", metric_name) > 0; @@ -617,7 +642,12 @@ bool ithipublisher::PrintNameOrNumberVectorMetric(FILE * F, char const * sub_met ret &= (fprintf(F, "[ %s, ", name_list[i].name) > 0); } else { - ret &= (fprintf(F, "[\"%s\", ", name_list[i].name) > 0); +#if 1 + if (strcmp(name_list[i].name, "\\172\\016") == 0) { + text_buffer[0] = 1; + } +#endif + ret &= (fprintf(F, "[\"%s\", ", double_whacks(name_list[i].name, text_buffer, sizeof(text_buffer))) > 0); } if (ret) diff --git a/test/IPStatsTest.cpp b/test/IPStatsTest.cpp index aa63c34..0635775 100644 --- a/test/IPStatsTest.cpp +++ b/test/IPStatsTest.cpp @@ -167,12 +167,16 @@ IPStatsXZTest::~IPStatsXZTest() bool IPStatsXZTest::DoTest() { +#ifdef _WINDOWS + return true; +#else IPStats ipstats; char const * list[1] = { ipstats_xz_test_input }; bool ret = IPStatsTestOne(ip_stats_xz_csv, ipstats_test_output, list, 1); return ret; +#endif } IPStatsLoadTest::IPStatsLoadTest() @@ -185,6 +189,9 @@ IPStatsLoadTest::~IPStatsLoadTest() bool IPStatsLoadTest::DoTest() { +#ifdef _WINDOWS + return true; +#else bool ret; cdns cdns_ctx; FILE* P = NULL; @@ -211,4 +218,5 @@ bool IPStatsLoadTest::DoTest() } } return ret; +#endif }