Imported Upstream version 2.7
[ossec-hids.git] / src / os_dbd / db_op.h
1 /* @(#) $Id: ./src/os_dbd/db_op.h, 2011/09/08 dcid Exp $
2  */
3
4 /* Copyright (C) 2009 Trend Micro Inc.
5  * All rights reserved.
6  *
7  * This program is a free software; you can redistribute it
8  * and/or modify it under the terms of the GNU General Public
9  * License (version 2) as published by the FSF - Free Software
10  * Foundation.
11  *
12  * License details at the LICENSE file included with OSSEC or
13  * online at: http://www.ossec.net/en/licensing.html
14  */
15
16 /* Common API for dealing with databases */
17
18
19 #ifndef _OS_DBOP_H
20 #define _OS_DBOP_H
21
22
23 /* Connects to the database */
24 void *(*osdb_connect)(char *host, char *user, char *pass, char *db, int port, char *sock);
25 void *mysql_osdb_connect(char *host, char *user, char *pass, char *db, int port, char *sock);
26 void *postgresql_osdb_connect(char *host, char *user, char *pass, char *db, int port, char *sock);
27
28 /* Sends insert query to the database */
29 int (* osdb_query_insert)(void *db_conn, char *query);
30 int mysql_osdb_query_insert(void *db_conn, char *query);
31 int postgresql_osdb_query_insert(void *db_conn, char *query);
32
33 /* Sends select query to the database */
34 int (* osdb_query_select)(void *db_conn, char *query);
35 int mysql_osdb_query_select(void *db_conn, char *query);
36 int postgresql_osdb_query_select(void *db_conn, char *query);
37
38 /* Closes connection to the database */
39 void *(*osdb_close)(void *db_conn);
40 void *mysql_osdb_close(void *db_conn);
41 void *postgresql_osdb_close(void *db_conn);
42
43
44 /* escape strings before inserting. */
45 void osdb_escapestr(char *str);
46
47
48 /* Allowed characters */
49 /* Insert charmap.
50  * Available chars: a-z, A-Z, 0-9, -, _, ., %, $, @, (, ), +, *, <space> /
51  * Basically: 040-046 (oct)
52  *            050-176 (oct)
53  * 8/27/2012: Modified to allow new lines - \012
54  */
55 static const unsigned char insert_map[] =
56 {
57     '\000', '\000', '\002', '\003', '\004', '\005', '\006', '\007',
58     '\010', '\011', '\001', '\013', '\014', '\015', '\016', '\017',
59     '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
60     '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
61     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\047',
62     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
63     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
64     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
65     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
66     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
67     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
68     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
69     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
70     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
71     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\001',
72     '\001', '\001', '\001', '\001', '\001', '\001', '\001', '\177',
73     '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
74     '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
75     '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
76     '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
77     '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
78     '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
79     '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
80     '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
81     '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
82     '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
83     '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
84     '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
85     '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
86     '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
87     '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
88     '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
89 };
90
91
92 #endif
93
94 /* EOF */