logswan

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

commit 34c64dd6c6a3312af4de44bb46de297c9e1b53e8
parent 7e34166cf67cdd89fdcb9e03d8d592114a96a466
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun, 19 Jul 2015 15:27:06 +0200

Removing duplicated methods and protocols declarations

Diffstat:
MCMakeLists.txt | 2+-
Asrc/definitions.c | 29+++++++++++++++++++++++++++++
Asrc/definitions.h | 20++++++++++++++++++++
Msrc/logswan.c | 18+-----------------
Msrc/output.c | 18+-----------------
5 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -21,7 +21,7 @@ find_library(LIB_GEOIP NAMES GeoIP REQUIRED) find_library(LIB_JANSSON NAMES jansson REQUIRED) set (DEPS deps/hll/hll.c deps/MurmurHash3/MurmurHash3.c) -set (SRC src/logswan.c src/output.c src/parse.c) +set (SRC src/logswan.c src/definitions.c src/output.c src/parse.c) if(NOT HAVE_STRTONUM) set (SRC ${SRC} compat/strtonum.c) diff --git a/src/definitions.c b/src/definitions.c @@ -0,0 +1,29 @@ +/*****************************************************************************/ +/* */ +/* Logswan (c) by Frederic Cambus 2015 */ +/* https://github.com/fcambus/logswan */ +/* */ +/* Created: 2015/05/31 */ +/* Last Updated: 2015/07/19 */ +/* */ +/* Logswan is released under the BSD 3-Clause license. */ +/* See LICENSE file for details. */ +/* */ +/*****************************************************************************/ + +char *methods[] = { + "OPTIONS", + "GET", + "HEAD", + "POST", + "PUT", + "DELETE", + "TRACE", + "CONNECT", + "PATCH" +}; + +char *protocols[] = { + "HTTP/1.0", + "HTTP/1.1" +}; diff --git a/src/definitions.h b/src/definitions.h @@ -0,0 +1,20 @@ +/*****************************************************************************/ +/* */ +/* Logswan (c) by Frederic Cambus 2015 */ +/* https://github.com/fcambus/logswan */ +/* */ +/* Created: 2015/05/31 */ +/* Last Updated: 2015/07/19 */ +/* */ +/* Logswan is released under the BSD 3-Clause license. */ +/* See LICENSE file for details. */ +/* */ +/*****************************************************************************/ + +#ifndef DEFINITIONS_H +#define DEFINITIONS_H + +extern char *methods[]; +extern char *protocols[]; + +#endif diff --git a/src/logswan.c b/src/logswan.c @@ -30,6 +30,7 @@ #include <GeoIP.h> #include "logswan.h" +#include "definitions.h" #include "output.h" #include "parse.h" #include "results.h" @@ -66,23 +67,6 @@ int main (int argc, char *argv[]) { hll_init(&uniqueIPv4, 20); hll_init(&uniqueIPv6, 20); - char *methods[] = { - "OPTIONS", - "GET", - "HEAD", - "POST", - "PUT", - "DELETE", - "TRACE", - "CONNECT", - "PATCH" - }; - - char *protocols[] = { - "HTTP/1.0", - "HTTP/1.1" - }; - printf("-------------------------------------------------------------------------------\n" \ " Logswan (c) by Frederic Cambus 2015 \n" \ "-------------------------------------------------------------------------------\n\n"); diff --git a/src/output.c b/src/output.c @@ -15,26 +15,10 @@ #include <jansson.h> #include "logswan.h" +#include "definitions.h" #include "results.h" char *output(Results results) { - char *methods[] = { - "OPTIONS", - "GET", - "HEAD", - "POST", - "PUT", - "DELETE", - "TRACE", - "CONNECT", - "PATCH" - }; - - char *protocols[] = { - "HTTP/1.0", - "HTTP/1.1" - }; - json_t *jsonObject = json_object(); json_t *hitsObject = json_object(); json_t *countriesArray = json_array();