logswan

Fast Web log analyzer using probabilistic data structures
Log | Files | Refs | README | LICENSE

commit d4065c509cf6b533d68ee96c8e4c9290fc792651
parent a32dd716cb7444c6b743acc2975c37cf92d45bdc
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Tue, 22 Dec 2015 22:55:44 +0100

Using a constant to define the number of countries

Diffstat:
Msrc/config.h | 3++-
Msrc/output.c | 4++--
Msrc/output.h | 4++--
3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/config.h b/src/config.h @@ -4,7 +4,7 @@ /* https://github.com/fcambus/logswan */ /* */ /* Created: 2015/05/31 */ -/* Last Updated: 2015/12/19 */ +/* Last Updated: 2015/12/22 */ /* */ /* Logswan is released under the BSD 3-Clause license. */ /* See LICENSE file for details. */ @@ -22,6 +22,7 @@ enum { STATUS_CODE_MAX = 512, CONTINENTS = 6, + COUNTRIES = 255, METHODS = 9, PROTOCOLS = 2 }; diff --git a/src/output.c b/src/output.c @@ -4,7 +4,7 @@ /* https://github.com/fcambus/logswan */ /* */ /* Created: 2015/05/31 */ -/* Last Updated: 2015/12/19 */ +/* Last Updated: 2015/12/22 */ /* */ /* Logswan is released under the BSD 3-Clause license. */ /* See LICENSE file for details. */ @@ -34,7 +34,7 @@ char *output(Results results) { } } - for (int loop=0; loop<255; loop++) { + for (int loop=0; loop<COUNTRIES; loop++) { if (results.countries[loop]) { json_array_append_new(countriesArray, json_pack("{s:s, s:s, s:i}", "data", GeoIP_code_by_id(loop), "name", GeoIP_name_by_id(loop), "hits", results.countries[loop])); } diff --git a/src/output.h b/src/output.h @@ -4,7 +4,7 @@ /* https://github.com/fcambus/logswan */ /* */ /* Created: 2015/05/31 */ -/* Last Updated: 2015/11/02 */ +/* Last Updated: 2015/12/22 */ /* */ /* Logswan is released under the BSD 3-Clause license. */ /* See LICENSE file for details. */ @@ -27,7 +27,7 @@ struct results { uint64_t visitsIPv4; uint64_t visitsIPv6; uint64_t continents[CONTINENTS]; - uint64_t countries[255]; + uint64_t countries[COUNTRIES]; uint64_t hours[24]; uint64_t status[STATUS_CODE_MAX]; double runtime;