| 1 | /* |
| 2 | * AIDE (Advanced Intrusion Detection Environment) |
| 3 | * |
| 4 | * Copyright (C) 1999-2002, 2004-2005, 2013, 2016, 2020, 2022-2025 Rami Lehti, |
| 5 | * Pablo Virolainen, Richard van den Berg, Hannes von Haugwitz |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of the |
| 10 | * License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _DB_H_INCLUDED |
| 23 | #define _DB_H_INCLUDED |
| 24 | |
| 25 | #include <stdbool.h> |
| 26 | #include <stdio.h> |
| 27 | #include "db_config.h" |
| 28 | #include "util.h" |
| 29 | |
| 30 | typedef enum { |
| 31 | DB_TYPE_IN, |
| 32 | DB_TYPE_OUT, |
| 33 | DB_TYPE_NEW, |
| 34 | } DB_TYPE; |
| 35 | |
| 36 | typedef struct { |
| 37 | db_line* line; |
| 38 | bool limit; |
| 39 | } db_entry_t; |
| 40 | |
| 41 | byte* base64tobyte(char*, int, size_t *); |
| 42 | |
| 43 | db_line* db_char2line(char**, database*); |
| 44 | |
| 45 | int db_init(database*, bool, bool); |
| 46 | |
| 47 | db_entry_t db_readline(database*, bool); |
| 48 | |
| 49 | int db_writespec(db_config*); |
| 50 | |
| 51 | int db_writeline(db_line*,db_config*); |
| 52 | |
| 53 | void db_close(void); |
| 54 | |
| 55 | void free_db_line(db_line* dl); |
| 56 | |
| 57 | #define DB_OLD (1<<0) |
| 58 | #define DB_DISK (1<<1) |
| 59 | #define DB_NEW (1<<2) |
| 60 | #define NODE_ADDED (1<<4) |
| 61 | #define NODE_REMOVED (1<<5) |
| 62 | #define NODE_CHANGED (1<<6) |
| 63 | #define NODE_FREE (1<<7) |
| 64 | |
| 65 | #define NODE_MOVED_OUT (1<<11) |
| 66 | #define NODE_MOVED_IN (1<<12) |
| 67 | #define NODE_ALLOW_NEW (1<<13) |
| 68 | #define NODE_ALLOW_RM (1<<14) |
| 69 | #define NODE_CHECK_INODE (1<<15) |
| 70 | #define NODE_HAS_SUB_RULES (1<<16) |
| 71 | |
| 72 | #define LOG_DB_FORMAT_LINE(log_level, format, ...) \ |
| 73 | log_msg(log_level, "%s:%li: " format , (db->url)->raw, db->lineno, __VA_ARGS__); |
| 74 | |
| 75 | #endif |