File: afsql.h

package info (click to toggle)
syslog-ng 4.8.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,456 kB
  • sloc: ansic: 177,631; python: 13,035; cpp: 11,611; makefile: 7,012; sh: 5,147; java: 3,651; xml: 3,344; yacc: 1,377; lex: 599; perl: 193; awk: 190; objc: 162
file content (128 lines) | stat: -rw-r--r-- 4,127 bytes parent folder | download | duplicates (2)
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
122
123
124
125
126
127
128
/*
 * Copyright (c) 2002-2012 Balabit
 * Copyright (c) 1998-2012 Balázs Scheidler
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, 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
 * GNU General Public License for more details.
 *
 * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * As an additional exemption you are allowed to compile & link against the
 * OpenSSL libraries as published by the OpenSSL project. See the file
 * COPYING for details.
 *
 */

#ifndef AFSQL_H_INCLUDED
#define AFSQL_H_INCLUDED

#pragma GCC diagnostic ignored "-Wstrict-prototypes"

#include "logthrdest/logthrdestdrv.h"
#include "mainloop-worker.h"
#include "string-list.h"

#include <dbi.h>

/* field flags */
enum
{
  AFSQL_FF_DEFAULT = 0x0001,
};

/* destination driver flags */
enum
{
  AFSQL_DDF_EXPLICIT_COMMITS = 0x1000,
  AFSQL_DDF_DONT_CREATE_TABLES = 0x2000,
};

typedef struct _AFSqlField
{
  guint32 flags;
  gchar *name;
  gchar *type;
  LogTemplate *value;
} AFSqlField;

/**
 * AFSqlDestDriver:
 *
 * This structure encapsulates an SQL destination driver. SQL insert
 * statements are generated from a separate thread because of the blocking
 * nature of the DBI API. It is ensured that while the thread is running,
 * the reference count to the driver structure is increased, thus the db
 * thread can read any of the fields in this structure. To do anything more
 * than simple reading out a value, some kind of locking mechanism shall be
 * used.
 **/
typedef struct _AFSqlDestDriver
{
  LogThreadedDestDriver super;
  /* read by the db thread */
  gchar *type;
  gchar *host;
  gchar *port;
  gchar *user;
  gchar *password;
  gchar *database;
  gchar *encoding;
  gchar *create_statement_append;
  GList *columns;
  GList *values;
  GList *indexes;
  LogTemplate *table;
  gint fields_len;
  AFSqlField *fields;
  gchar *null_value;
  gchar *quote_as_string;
  gboolean ignore_tns_config;
  GList *session_statements;

  LogTemplateOptions template_options;

  GHashTable *dbd_options;
  GHashTable *dbd_options_numeric;

  /* used exclusively by the db thread */
  dbi_conn dbi_ctx;
  gchar *dbi_driver_dir;
  GHashTable *syslogng_conform_tables;
  guint32 failed_message_counter;
  gboolean transaction_active;
} AFSqlDestDriver;


void afsql_dd_set_type(LogDriver *s, const gchar *type);
void afsql_dd_set_host(LogDriver *s, const gchar *host);
void afsql_dd_set_port(LogDriver *s, const gchar *port);
void afsql_dd_set_user(LogDriver *s, const gchar *user);
void afsql_dd_set_password(LogDriver *s, const gchar *password);
void afsql_dd_set_database(LogDriver *s, const gchar *database);
void afsql_dd_set_table(LogDriver *s, LogTemplate *table_template);
void afsql_dd_set_columns(LogDriver *s, GList *columns);
void afsql_dd_set_values(LogDriver *s, GList *values);
void afsql_dd_set_null_value(LogDriver *s, const gchar *null);
void afsql_dd_set_indexes(LogDriver *s, GList *indexes);
void afsql_dd_set_session_statements(LogDriver *s, GList *session_statements);
void afsql_dd_set_create_statement_append(LogDriver *s, const gchar *create_statement_append);
LogDriver *afsql_dd_new(GlobalConfig *cfg);
gint afsql_dd_lookup_flag(const gchar *flag);
void afsql_dd_add_dbd_option(LogDriver *s, const gchar *name, const gchar *value);
void afsql_dd_add_dbd_option_numeric(LogDriver *s, const gchar *name, gint value);
void afsql_dd_set_dbi_driver_dir(LogDriver *s, const gchar *dbi_driver_dir);
void afsql_dd_set_quote_char(LogDriver *s, const gchar *quote);
void afsql_dd_set_ignore_tns_config(LogDriver *s, const gboolean ignore_tns_config);

gboolean afsql_dd_process_flag(LogDriver *driver, const gchar *flag);


#endif