Imported Upstream version 2.4.3
[platform/upstream/audit.git] / auparse / internal.h
1 /* internal.h -- 
2  * Copyright 2006-07,2013-14 Red Hat Inc., Durham, North Carolina.
3  * All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  * 
19  * Authors:
20  *      Steve Grubb <sgrubb@redhat.com>
21  */
22 #ifndef AUPARSE_INTERNAL_HEADER
23 #define AUPARSE_INTERNAL_HEADER
24
25 #include "auparse-defs.h"
26 #include "ellist.h"
27 #include "auditd-config.h"
28 #include "data_buf.h"
29 #include "dso.h"
30 #include <stdio.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /* This is what state the parser is in */
37 typedef enum { EVENT_EMPTY, EVENT_ACCUMULATING, EVENT_EMITTED } auparser_state_t;
38
39 /* This is the name/value pair used by search tables */
40 struct nv_pair {
41         int        value;
42         const char *name;
43 };
44
45 struct opaque
46 {
47         ausource_t source;              // Source type
48         char **source_list;             // Array of buffers, or array of
49                                         //       file names
50         int list_idx;                   // The index into the source list
51         FILE *in;                       // If source is file, this is the fd
52         unsigned int line_number;       // line number of current file, zero
53                                         //       if invalid
54         char *next_buf;                 // The current buffer being broken down
55         unsigned int off;               // The current offset into next_buf
56         char *cur_buf;                  // The current buffer being parsed
57         int line_pushed;                // True if retrieve_next_line() 
58                                         //      returns same input
59         event_list_t le;                // Linked list of record in same event
60         struct expr *expr;              // Search expression or NULL
61         char *find_field;               // Used to store field name when
62                                         //       searching
63         austop_t search_where;          // Where to put the cursors on a match
64         auparser_state_t parse_state;   // parsing state
65         DataBuf databuf;                // input data
66
67         // function to call to notify user of parsing changes
68         void (*callback)(struct opaque *au, auparse_cb_event_t cb_event_type, void *user_data);
69
70         void *callback_user_data;       // user data supplied to callback
71
72         // function to call when user_data is destroyed
73         void (*callback_user_data_destroy)(void *user_data);
74 };
75
76 // auditd-config.c
77 void clear_config(struct daemon_conf *config) hidden;
78 int load_config(struct daemon_conf *config, log_test_t lt) hidden;
79 void free_config(struct daemon_conf *config) hidden;
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif
86