-
Notifications
You must be signed in to change notification settings - Fork 7
/
logFile.h
121 lines (105 loc) · 4.03 KB
/
logFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
* Copyright (C) 2019 by John D. Robertson *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOGFILE_H
#define LOGFILE_H
#define _GNU_SOURCE
#include <stdio.h>
#include "logType.h"
#include "map.h"
/* One of these for each log file which is scanned. */
typedef struct _LOGFILE {
int flags;
char *logFname;
struct {
MAP offEntry_map,
obsvTpl_map;
} addr; /* addr denotes the map keys */
unsigned nOffenses;
} LOGFILE;
#define LOGFILE_logFname(self) \
(const char*)(self)->logFname
#ifdef __cplusplus
extern "C" {
#endif
#define LOGFILE_cache_create(s, cacheFname, logFname) \
((s)=(LOGFILE_cache_constructor((s)=malloc(sizeof(LOGFILE)), cacheFname, logFname) ? (s) : ( s ? realloc(LOGFILE_destructor(s),0) : 0 )))
LOGFILE*
LOGFILE_cache_constructor(
LOGFILE *self,
const char *cacheFname,
const char *logFname
);
/******************************************************************
* Initialize an instance of a LOGFILE class.
*/
#define LOGFILE_log_create(s, h_protoType, logFname) \
((s)=(LOGFILE_log_constructor((s)=malloc(sizeof(LOGFILE)), h_protoType, logFname) ? (s) : ( s ? realloc(LOGFILE_destructor(s),0) : 0 )))
LOGFILE*
LOGFILE_log_constructor(
LOGFILE *self,
const struct logProtoType *h_protoType,
const char *logFname
);
/******************************************************************
* Initialize an instance of a LOGFILE class.
*/
#define LOGFILE_destroy(s) \
{if(LOGFILE_destructor(s)) {free(s);(s)=0;}}
LOGFILE*
LOGFILE_destructor(LOGFILE *self);
/******************************************************************
* Free resources associated with a LOGFILE object.
*/
#if 0
void
LOGFILE_set_logFname(LOGFILE *self, const char *path);
/******************************************************************
* Set the log file name by making a copy of the path.
*/
#endif
int
LOGFILE_writeCache(LOGFILE *self, const char *fname);
/******************************************************************
* Create a cache file and dump contents of this object.
*/
int
LOGFILE_print(LOGFILE *self, FILE *fh);
/********************************************************
* Print a human readable representation of *self.
*/
int
LOGFILE_map_addr(LOGFILE *self, MAP *h_rtnMap);
/********************************************************
* Create a map of OFFENTRY objects with composite
* counts by address.
*/
int
LOGFILE_offenseCount(LOGFILE *self, unsigned *h_sum);
/********************************************************
* Get a count of all offenses for this file.
*/
int
LOGFILE_addressCount(LOGFILE *self, unsigned *h_sum);
/********************************************************
* Get a count of all unique addresses for this file.
*/
#ifdef __cplusplus
}
#endif
#endif /* LOGFILE_H */