Files | |
file | xdm_odbc.c |
OpenXDAS loadable back-end logger for an odbc-based SQL database audit log. | |
Data Structures | |
struct | xdr_tag |
XDAS field data record structure. More... | |
struct | pa_tag |
Parameter table drives msg parser and SQLBindParameter calls. More... | |
Defines | |
#define | SQL_Window 1 |
#define | XDMAPI |
#define | XDMEXP |
#define | ARRAYSZ(x) (sizeof(x)/sizeof(*(x))) |
#define | XDM_DEF_CONNSTR "DSN=xdas;" |
Default ODBC SQLDriverConnect string. | |
Functions | |
static void | logsqlerr (const char *fn, SQLHANDLE handle, SQLSMALLINT type, SQLRETURN rc) |
XDM logger function for odbc error data. | |
static int | getmsgparam (const char *cp, const char *ep, SQLSMALLINT type, SQLPOINTER buf, SQLUINTEGER bufsz) |
Convert and copy a string field value into a typed buffer. | |
static int | parsemsg (const char **msgflds) |
Process an XDAS record into XDR fields for insertion into database. | |
static void | sql_disconnect (void) |
Disconnect from ODBC data source and clear global handles. | |
static int | sql_connect (void) |
Connect to SQL server and and prepare a statement. | |
XDMEXP int XDMAPI | xdm_append (const char **msgflds) |
XDM module append routine. | |
XDMEXP void XDMAPI | xdm_exit (void) |
XDM module exit routine. | |
XDMEXP int XDMAPI | xdm_init (void(*logmsg)(int level, const char *msg,...), char *(*getcnfstr)(const char *, char *, size_t *)) |
XDM module initialization routine. | |
Variables | |
static void(* | s_fplogmsg )(int level, const char *msg,...)=0 |
A pointer to the xdasd logmsg function. | |
static char *(* | s_fpgetcnfstr )(const char *, char *, size_t *)=0 |
A pointer to the xdasd get_conf_string function. | |
static SQLHENV | hsql = 0 |
SQL variables. | |
static SQLHDBC | hdbc = 0 |
static SQLHSTMT | hstmt = 0 |
static SQLCHAR * | primary_stmt |
SQL prepared INSERT statement. | |
static struct xdr_tag | xdr |
XDAS field data record structure. | |
static struct pa_tag | pa [] |
Parameter table drives msg parser and SQLBindParameter calls. | |
static SQLINTEGER | ind [ARRAYSZ(pa)] |
#define ARRAYSZ | ( | x | ) | (sizeof(x)/sizeof(*(x))) |
#define SQL_Window 1 |
#define XDM_DEF_CONNSTR "DSN=xdas;" |
Default ODBC SQLDriverConnect string.
Definition at line 68 of file xdm_odbc.c.
Referenced by sql_connect().
#define XDMAPI |
Definition at line 58 of file xdm_odbc.c.
#define XDMEXP |
Definition at line 59 of file xdm_odbc.c.
static int getmsgparam | ( | const char * | cp, | |
const char * | ep, | |||
SQLSMALLINT | type, | |||
SQLPOINTER | buf, | |||
SQLUINTEGER | bufsz | |||
) | [static] |
Convert and copy a string field value into a typed buffer.
For internal use only.
Definition at line 195 of file xdm_odbc.c.
Referenced by parsemsg().
static void logsqlerr | ( | const char * | fn, | |
SQLHANDLE | handle, | |||
SQLSMALLINT | type, | |||
SQLRETURN | rc | |||
) | [static] |
XDM logger function for odbc error data.
For internal use only.
Definition at line 171 of file xdm_odbc.c.
References s_fplogmsg.
Referenced by sql_connect(), and xdm_append().
static int parsemsg | ( | const char ** | msgflds | ) | [static] |
Process an XDAS record into XDR fields for insertion into database.
For internal use only.
Definition at line 231 of file xdm_odbc.c.
References ARRAYSZ, getmsgparam(), and pa.
Referenced by xdm_append().
static int sql_connect | ( | void | ) | [static] |
Connect to SQL server and and prepare a statement.
Definition at line 261 of file xdm_odbc.c.
References ARRAYSZ, pa_tag::blen, hdbc, hsql, hstmt, ind, logsqlerr(), pa, primary_stmt, sql_disconnect(), SQL_Window, and XDM_DEF_CONNSTR.
Referenced by xdm_append().
static void sql_disconnect | ( | void | ) | [static] |
Disconnect from ODBC data source and clear global handles.
Definition at line 247 of file xdm_odbc.c.
Referenced by sql_connect(), xdm_append(), and xdm_exit().
XDMEXP int XDMAPI xdm_append | ( | const char ** | msgflds | ) |
XDM module append routine.
[in] | msgflds | - an array of 34 char ptrs that point into the message at the start of each field. The last pointer (numbered 33) points to the byte that is 2 beyond the last printable character of the last field. |
For internal use only.
Definition at line 330 of file xdm_odbc.c.
References hdbc, hstmt, logsqlerr(), parsemsg(), sql_connect(), and sql_disconnect().
XDMEXP void XDMAPI xdm_exit | ( | void | ) |
XDM module exit routine.
For internal use only.
Definition at line 373 of file xdm_odbc.c.
References hsql, and sql_disconnect().
XDMEXP int XDMAPI xdm_init | ( | void(*)(int level, const char *msg,...) | logmsg, | |
char *(*)(const char *, char *, size_t *) | getcnfstr | |||
) |
XDM module initialization routine.
For internal use only.
Definition at line 386 of file xdm_odbc.c.
References hsql, s_fpgetcnfstr, and s_fplogmsg.
SQLHDBC hdbc = 0 [static] |
Definition at line 78 of file xdm_odbc.c.
Referenced by sql_connect(), sql_disconnect(), and xdm_append().
SQLHENV hsql = 0 [static] |
SQL variables.
Definition at line 77 of file xdm_odbc.c.
Referenced by sql_connect(), xdm_exit(), and xdm_init().
SQLHSTMT hstmt = 0 [static] |
Definition at line 79 of file xdm_odbc.c.
Referenced by sql_connect(), sql_disconnect(), and xdm_append().
Parameter table drives msg parser and SQLBindParameter calls.
Referenced by parsemsg(), and sql_connect().
SQLCHAR* primary_stmt [static] |
Initial value:
(SQLCHAR *) "INSERT INTO xdas (xdasver, timestamp, tmuncert_int, tmuncert_ind, " "timesrc, tz, event, outcome, org_loc, org_addr, org_type, org_auth, " "org_pname, org_pid, int_auth, int_dsname, int_dsid, tgt_loc, tgt_addr, " "tgt_type, tgt_auth, tgt_pname, tgt_pid, esrc, edata) VALUES " "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
Definition at line 82 of file xdm_odbc.c.
Referenced by sql_connect().
char*(* s_fpgetcnfstr)(const char *, char *, size_t *)=0 [static] |
A pointer to the xdasd get_conf_string function.
void(* s_fplogmsg)(int level, const char *msg,...)=0 [static] |
A pointer to the xdasd logmsg function.