diff options
author | Luca Deri <deri@ntop.org> | 2020-01-20 23:37:09 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-01-20 23:37:09 +0100 |
commit | 931f51bd77b2b863cab010064d2a2d0b4f968f7e (patch) | |
tree | 2ecd0713f433cba93ea4473f5911d5f72d0b1bfa | |
parent | 283588a37b313973d86fa04f821c0f071e26349b (diff) |
ndpi_load_categories_file() now returns the number of loaded hosts or -1 in case of error
-rw-r--r-- | src/lib/ndpi_main.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 088847c8a..90c9a81a4 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -2846,7 +2846,7 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, int ndpi_load_categories_file(struct ndpi_detection_module_struct *ndpi_str, const char* path) { char buffer[512], *line, *name, *category, *saveptr; FILE *fd; - int len; + int len, num = 0; fd = fopen(path, "r"); @@ -2872,15 +2872,19 @@ int ndpi_load_categories_file(struct ndpi_detection_module_struct *ndpi_str, con if(name) { category = strtok_r(NULL, "\t", &saveptr); - if(category) - ndpi_load_category(ndpi_str, name, (ndpi_protocol_category_t) atoi(category)); + if(category) { + int rc = ndpi_load_category(ndpi_str, name, (ndpi_protocol_category_t) atoi(category)); + + if(rc >= 0) + num++; + } } } fclose(fd); ndpi_enable_loaded_categories(ndpi_str); - return(0); + return(num); } /* ******************************************************************** */ |