<commit_before>/*****************************************************************************/
/*                                                                           */
/* Logswan 1.06                                                              */
/* Copyright (c) 2015-2017, <NAME>                                  */
/* http://www.logswan.org                                                    */
/*                                                                           */
/* Created:      2015-05-31                                                  */
/* Last Updated: 2017-01-12                                                  */
/*                                                                           */
/* Logswan is released under the BSD 2-Clause license.                       */
/* See LICENSE file for details.                                             */
/*                                                                           */
/*****************************************************************************/

#define _XOPEN_SOURCE 600
#define _POSIX_SOURCE

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <getopt.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#ifndef HAVE_PLEDGE
#include "pledge.h"
#endif

#ifndef HAVE_STRTONUM
#include "strtonum.h"
#endif

#include "hll.h"

#include <GeoIP.h>

#include "config.h"
#include "output.h"
#include "parse.h"

bool geoip;
GeoIP *geoipv4 = NULL, *geoipv6 = NULL;

clock_t begin, end;

char lineBuffer[LINE_MAX_LENGTH];

struct results results;
struct date parsedDate;
struct logLine parsedLine;
struct request parsedRequest;

struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
uint32_t isIPv4, isIPv6;

uint64_t bandwidth;
uint32_t statusCode;
uint32_t hour;
uint32_t countryId;

FILE *logFile;
struct stat logFileStat;

const char *errstr;

int8_t getoptFlag;

struct HLL uniqueIPv4, uniqueIPv6;
char *intputFile;

void
displayUsage() {
	printf("USAGE : logswan [options] inputfile\n\n" \
	       "Options are :\n\n" \
	       "	-g Enable GeoIP lookups\n" \
	       "	-h Display usage\n" \
	       "	-v Display version\n\n");
}

int
main(int argc, char *argv[]) {
	if (pledge("stdio rpath", NULL) == -1) {
		err(1, "pledge");
	}

	hll_init(&uniqueIPv4, HLL_BITS);
	hll_init(&uniqueIPv6, HLL_BITS);

	while ((getoptFlag = getopt(argc, argv, "ghv")) != -1) {
		switch(getoptFlag) {
		case 'g':
			geoip = true;
			break;

		case 'h':
			displayUsage();
			return 0;

		case 'v':
			printf("%s\n\n", VERSION);
			return 0;
		}
	}

	if (optind < argc) {<commit_msg>Formatting fixes<commit_after>/*****************************************************************************/
/*                                                                           */
/* Logswan 1.06                                                              */
/* Copyright (c) 2015-2017, <NAME>                                  */
/* http://www.logswan.org                                                    */
/*                                                                           */
/* Created:      2015-05-31                                                  */
/* Last Updated: 2017-01-12                                                  */
/*                                                                           */
/* Logswan is released under the BSD 2-Clause license.                       */
/* See LICENSE file for details.                                             */
/*                                                                           */
/*****************************************************************************/

#define _XOPEN_SOURCE 600
#define _POSIX_SOURCE

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <getopt.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#ifndef HAVE_PLEDGE
#include "pledge.h"
#endif

#ifndef HAVE_STRTONUM
#include "strtonum.h"
#endif

#include "hll.h"

#include <GeoIP.h>

#include "config.h"
#include "output.h"
#include "parse.h"

bool geoip;
GeoIP *geoipv4 = NULL, *geoipv6 = NULL;

clock_t begin, end;

char lineBuffer[LINE_MAX_LENGTH];

struct results results;
struct date parsedDate;
struct logLine parsedLine;
struct request parsedRequest;

struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
uint32_t isIPv4, isIPv6;

uint64_t bandwidth;
uint32_t statusCode;
uint32_t hour;
uint32_t countryId;

FILE *logFile;
struct stat logFileStat;

const char *errstr;

int8_t getoptFlag;

struct HLL uniqueIPv4, uniqueIPv6;
char *intputFile;

void
displayUsage() {
	printf("USAGE: logswan [options] inputfile\n\n" \
	       "Options are:\n\n" \
	       "	-g Enable GeoIP lookups\n" \
	       "	-h Display usage\n" \
	       "	-v Display version\n\n");
}

int
main(int argc, char *argv[]) {
	if (pledge("stdio rpath", NULL) == -1) {
		err(1, "pledge");
	}

	hll_init(&uniqueIPv4, HLL_BITS);
	hll_init(&uniqueIPv6, HLL_BITS);

	while ((getoptFlag = getopt(argc, argv, "ghv")) != -1) {
		switch(getoptFlag) {
		case 'g':
			geoip = true;
			break;

		case 'h':
			displayUsage();
			return 0;

		case 'v':
			printf("%s\n\n", VERSION);
			return 0;
		}
	}

	if (optind < argc) {
{'fraction_non_alphanumeric': 0.1735613164184593, 'fraction_numerical': 0.02132744989887847, 'mean_word_length': 1.6433430515063168, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '174661', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1613, 'n_words': 390}