From: Andrea Zagli Date: Wed, 27 Oct 2010 14:50:15 +0000 (+0200) Subject: Changed name beacuase libaudit already exists. X-Git-Tag: 0.5.0~3 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=298aad57bf17ffe672502ef84ca072019bcd4ccb;p=zakaudit%2Flibzakaudit Changed name beacuase libaudit already exists. --- diff --git a/.gitignore b/.gitignore index 90465cc..ea19dd6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ depcomp docs/reference/version.xml gtk-doc.make install-sh -libaudit.pc +libzakaudit.pc libtool ltmain.sh m4 @@ -32,4 +32,4 @@ docs/reference/xml *.bak test1 *.exe -libaudit*tar* +libzakaudit*tar* diff --git a/Makefile.am b/Makefile.am index a04d10b..f8d72d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = src docs tests EXTRA_DIST = \ - libaudit.pc.in + libzakaudit.pc.in pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libaudit.pc +pkgconfig_DATA = libzakaudit.pc diff --git a/autogen.sh b/autogen.sh index f0edcfa..a7fc8d6 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,13 +4,13 @@ srcdir=`dirname $0` test -z "$srcdir" && srcdir=. -PKG_NAME="libaudit" +PKG_NAME="libzakaudit" (test -f $srcdir/configure.ac \ && test -d $srcdir/src \ - && test -f $srcdir/src/libaudit.h) || { + && test -f $srcdir/src/libzakaudit.h) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" - echo " top-level libaudit directory" + echo " top-level libzakaudit directory" exit 1 } diff --git a/configure.ac b/configure.ac index 4a829df..ba5ead1 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([libaudit], [0.0.2], [azagli@libero.it]) +AC_INIT([libzakaudit], [0.0.2], [azagli@libero.it]) AC_CONFIG_SRCDIR([src/audit.c]) AC_CONFIG_HEADER([config.h]) @@ -28,10 +28,10 @@ if test "x$HAVE_PKGCONFIG" = "xno"; then AC_MSG_ERROR(you need to have pkgconfig installed !) fi -PKG_CHECK_MODULES(LIBAUDIT, libgdaex >= $GDAEX_REQUIRED) +PKG_CHECK_MODULES(LIBZAKAUDIT, libgdaex >= $GDAEX_REQUIRED) -AC_SUBST(LIBAUDIT_CFLAGS) -AC_SUBST(LIBAUDIT_LIBS) +AC_SUBST(LIBZAKAUDIT_CFLAGS) +AC_SUBST(LIBZAKAUDIT_LIBS) # Checks for header files. @@ -42,7 +42,7 @@ AC_STRUCT_TM # Checks for library functions. AC_CONFIG_FILES([ - libaudit.pc + libzakaudit.pc Makefile src/Makefile docs/Makefile diff --git a/libaudit.pc.in b/libaudit.pc.in deleted file mode 100644 index dfeecb0..0000000 --- a/libaudit.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: @PACKAGE_NAME@ -Description: Database auditing -Version: @PACKAGE_VERSION@ -Requires: libgdaex -Libs: -L${libdir} -laudit -Cflags: -I${includedir} diff --git a/libzakaudit.pc.in b/libzakaudit.pc.in new file mode 100644 index 0000000..d0e9dc3 --- /dev/null +++ b/libzakaudit.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE_NAME@ +Description: Database auditing +Version: @PACKAGE_VERSION@ +Requires: libgdaex +Libs: -L${libdir} -lzakaudit +Cflags: -I${includedir} diff --git a/src/Makefile.am b/src/Makefile.am index 1453091..bd8e1d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,15 +1,15 @@ INCLUDES = $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ - $(LIBAUDIT_CFLAGS) + $(LIBZAKAUDIT_CFLAGS) -LIBS = $(LIBAUDIT_LIBS) +LIBS = $(LIBZAKAUDIT_LIBS) -lib_LTLIBRARIES = libaudit.la +lib_LTLIBRARIES = libzakaudit.la -libaudit_la_SOURCES = \ +libzakaudit_la_SOURCES = \ audit.c -libaudit_la_LDFLAGS = -no-undefined +libzakaudit_la_LDFLAGS = -no-undefined include_HEADERS = \ - libaudit.h + libzakaudit.h diff --git a/src/audit.c b/src/audit.c index c1030d8..1c9f6e1 100644 --- a/src/audit.c +++ b/src/audit.c @@ -3,7 +3,7 @@ * * Copyright (C) 2005-2010 Andrea Zagli * - * This file is part of libaudit. + * This file is part of libzak_audit. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include -#include "libaudit.h" +#include "libzakaudit.h" typedef struct { @@ -54,25 +54,25 @@ typedef struct GList *tables; } Datasource; -static void audit_class_init (AuditClass *klass); -static void audit_init (Audit *audit); +static void zak_audit_class_init (ZakAuditClass *klass); +static void zak_audit_init (ZakAudit *zak_audit); -static Audit *audit_new_ (void); -static gboolean load_fields (Audit *audit, +static ZakAudit *zak_audit_new_ (void); +static gboolean load_fields (ZakAudit *zak_audit, Datasource *datasource, Table *table); -static gboolean load_tables (Audit *audit, +static gboolean load_tables (ZakAudit *zak_audit, Datasource *datasource); -static gboolean load_datasources (Audit *audit); -static Field *get_field_from_name (Audit *audit, +static gboolean load_datasources (ZakAudit *zak_audit); +static Field *get_field_from_name (ZakAudit *zak_audit, Table *table, const char *field); -static Table *get_table_from_name (Audit *audit, +static Table *get_table_from_name (ZakAudit *zak_audit, Datasource *datasource, const char *table); -static Datasource *get_datasource_from_name (Audit *audit, +static Datasource *get_datasource_from_name (ZakAudit *zak_audit, const char *datasource); -static gboolean insert_value (Audit *audit, +static gboolean insert_value (ZakAudit *zak_audit, gint id_actions, Table *table, gchar *field_name, @@ -80,19 +80,19 @@ static gboolean insert_value (Audit *audit, static gchar *string_unquote (const gchar *value); static void parse_cond (GdaSqlExpr *cond, gchar **str); -static void audit_set_property (GObject *object, +static void zak_audit_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void audit_get_property (GObject *object, +static void zak_audit_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -#define AUDIT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUDIT, AuditPrivate)) +#define ZAK_AUDIT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ZAK_AUDIT, ZakAuditPrivate)) -typedef struct _AuditPrivate AuditPrivate; -struct _AuditPrivate +typedef struct _ZakAuditPrivate ZakAuditPrivate; +struct _ZakAuditPrivate { GdaEx *gdaex; GList *datasources; @@ -101,40 +101,40 @@ struct _AuditPrivate }; /* PRIVATE */ -G_DEFINE_TYPE (Audit, audit, G_TYPE_OBJECT) +G_DEFINE_TYPE (ZakAudit, zak_audit, G_TYPE_OBJECT) static void -audit_class_init (AuditClass *klass) +zak_audit_class_init (ZakAuditClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (AuditPrivate)); + g_type_class_add_private (object_class, sizeof (ZakAuditPrivate)); - object_class->set_property = audit_set_property; - object_class->get_property = audit_get_property; + object_class->set_property = zak_audit_set_property; + object_class->get_property = zak_audit_get_property; } static void -audit_init (Audit *audit) +zak_audit_init (ZakAudit *zak_audit) { - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); priv->datasources = NULL; priv->fields_updated = NULL; } -static Audit -*audit_new_ () +static ZakAudit +*zak_audit_new_ () { - Audit *audit; + ZakAudit *zak_audit; - audit = AUDIT (g_object_new (audit_get_type (), NULL)); + zak_audit = ZAK_AUDIT (g_object_new (zak_audit_get_type (), NULL)); - return audit; + return zak_audit; } static gboolean -load_fields (Audit *audit, +load_fields (ZakAudit *zak_audit, Datasource *datasource, Table *table) { @@ -146,7 +146,7 @@ load_fields (Audit *audit, Field *cam; - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); /* check if table exists */ dm_table = gdaex_query (datasource->gdaex, @@ -216,7 +216,7 @@ load_fields (Audit *audit, } static gboolean -load_tables (Audit *audit, +load_tables (ZakAudit *zak_audit, Datasource *datasource) { GdaDataModel *dm; @@ -224,7 +224,7 @@ load_tables (Audit *audit, gint rows, row; Table *tab; - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); sql = g_strdup_printf ("SELECT id, name FROM tables" " WHERE status <> 'D' AND id_datasources = %d", @@ -258,7 +258,7 @@ load_tables (Audit *audit, tab->fields_sql = NULL; tab->keys = NULL; tab->keys_sql = NULL; - if (!load_fields (audit, datasource, tab)) + if (!load_fields (zak_audit, datasource, tab)) { return FALSE; } @@ -270,14 +270,14 @@ load_tables (Audit *audit, } static gboolean -load_datasources (Audit *audit) +load_datasources (ZakAudit *zak_audit) { GdaDataModel *dm; gchar *sql; gint rows, row; Datasource *datas; - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); /* for each datasource on datasources table must be opened a connection */ dm = gdaex_query (priv->gdaex, "SELECT id, name, cnc_string" @@ -313,7 +313,7 @@ load_datasources (Audit *audit) /* for each datasource must be loaded tables and fields */ datas->tables = NULL; - if (!load_tables (audit, datas)) + if (!load_tables (zak_audit, datas)) { return FALSE; } @@ -323,7 +323,7 @@ load_datasources (Audit *audit) } static Field -*get_field_from_name (Audit *audit, +*get_field_from_name (ZakAudit *zak_audit, Table *table, const char *field) { @@ -347,7 +347,7 @@ static Field } static Table -*get_table_from_name (Audit *audit, +*get_table_from_name (ZakAudit *zak_audit, Datasource *datasource, const char *table) { @@ -371,10 +371,10 @@ static Table } static Datasource -*get_datasource_from_name (Audit *audit, +*get_datasource_from_name (ZakAudit *zak_audit, const char *datasource) { - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); GList *f = g_list_first (priv->datasources); @@ -396,7 +396,7 @@ static Datasource } static gboolean -insert_value (Audit *audit, +insert_value (ZakAudit *zak_audit, gint id_actions, Table *table, gchar *field_name, @@ -405,9 +405,9 @@ insert_value (Audit *audit, gchar *sql; gchar *real_value; - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); - Field *field = get_field_from_name (audit, table, field_name); + Field *field = get_field_from_name (zak_audit, table, field_name); if (field == NULL) { g_warning ("Unable to find the field \"%s\" on loaded fields.", @@ -492,11 +492,11 @@ static gchar } static void -audit_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +zak_audit_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Audit *audit = AUDIT (object); + ZakAudit *zak_audit = ZAK_AUDIT (object); - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); switch (property_id) { @@ -507,11 +507,11 @@ audit_set_property (GObject *object, guint property_id, const GValue *value, GPa } static void -audit_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +zak_audit_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Audit *audit = AUDIT (object); + ZakAudit *zak_audit = ZAK_AUDIT (object); - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); switch (property_id) { @@ -524,17 +524,17 @@ audit_get_property (GObject *object, guint property_id, GValue *value, GParamSpe /* PUBLIC */ /** - * audit_new: + * zak_audit_new: * @gda_connection: a #GdaConnection object. * - * Returns: the newly #Audit object. + * Returns: the newly #ZakAudit object. */ -Audit -*audit_new (GdaConnection *gda_connection) +ZakAudit +*zak_audit_new (GdaConnection *gda_connection) { - Audit *audit = audit_new_ (); + ZakAudit *zak_audit = zak_audit_new_ (); - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); priv->gdaex = gdaex_new_from_connection (gda_connection); @@ -546,28 +546,28 @@ Audit } /* carico i datasource */ - if (!load_datasources (audit)) + if (!load_datasources (zak_audit)) { /* TODO */ g_message ("Error loading datasources."); return NULL; } - return audit; + return zak_audit; } /** - * audit_new_from_string: + * zak_audit_new_from_string: * @cnc_string: the connection string to the datasource that contains library's tables. * - * Returns: the newly #Audit object. + * Returns: the newly #ZakAudit object. */ -Audit -*audit_new_from_string (const gchar *cnc_string) +ZakAudit +*zak_audit_new_from_string (const gchar *cnc_string) { - Audit *audit = audit_new_ (); + ZakAudit *zak_audit = zak_audit_new_ (); - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); priv->gdaex = gdaex_new_from_string (cnc_string); @@ -579,19 +579,19 @@ Audit } /* carico i datasource */ - if (!load_datasources (audit)) + if (!load_datasources (zak_audit)) { /* TODO */ g_message ("Error loading datasources."); return NULL; } - return audit; + return zak_audit; } /** - * audit_action: - * @audit: an #Audit object. + * zak_audit_action: + * @zak_audit: an #ZakAudit object. * @action: the action's type. * @username: the username that make the action. * @datasource_name: the datasource's name. @@ -601,8 +601,8 @@ Audit * Returns: #TRUE on success. */ gboolean -audit_action (Audit *audit, - enum AuditActions action, +zak_audit_action (ZakAudit *zak_audit, + enum ZakAuditActions action, const gchar *username, const gchar *datasource_name, const gchar *table_name, @@ -636,7 +636,7 @@ audit_action (Audit *audit, if (g_strcmp0 (str, "") != 0) { - ret = audit_action_v (audit, action, username, datasource_name, table_name, (const gchar **)g_strsplit (str, "|", -1)); + ret = zak_audit_action_v (zak_audit, action, username, datasource_name, table_name, (const gchar **)g_strsplit (str, "|", -1)); } return ret; @@ -675,8 +675,8 @@ static gchar } /** - * audit_action_v: - * @audit: an #Audit object. + * zak_audit_action_v: + * @zak_audit: an #ZakAudit object. * @action: the action's type. * @username: the username that make the action. * @datasource_name: the datasource's name. @@ -687,8 +687,8 @@ static gchar * Returns: #TRUE on success. */ gboolean -audit_action_v (Audit *audit, - enum AuditActions action, +zak_audit_action_v (ZakAudit *zak_audit, + enum ZakAuditActions action, const gchar *username, const gchar *datasource_name, const gchar *table_name, @@ -710,7 +710,7 @@ audit_action_v (Audit *audit, Datasource *datasource; Table *table; - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); if (action < 1) { @@ -732,7 +732,7 @@ audit_action_v (Audit *audit, tm_ora = localtime (&t); /* trovo il datasource */ - datasource = get_datasource_from_name (audit, datasource_name); + datasource = get_datasource_from_name (zak_audit, datasource_name); if (datasource == NULL) { g_warning ("Unable to find the datasource \"%s\" on loaded datasources.", @@ -741,7 +741,7 @@ audit_action_v (Audit *audit, } /* find the table */ - table = get_table_from_name (audit, datasource, table_name); + table = get_table_from_name (zak_audit, datasource, table_name); if (table == NULL) { g_warning ("Unable to find the table \"%s\" on loaded tables.", @@ -750,7 +750,7 @@ audit_action_v (Audit *audit, } /* saving the action */ - if (action != AUDIT_ACTION_BEFORE_UPDATE) + if (action != ZAK_AUDIT_ACTION_BEFORE_UPDATE) { /* TODO find the way to save more than 2 digits for the seconds */ sql = g_strdup_printf ("INSERT INTO actions" @@ -768,7 +768,7 @@ audit_action_v (Audit *audit, /* fields */ switch (action) { - case AUDIT_ACTION_INSERT: + case ZAK_AUDIT_ACTION_INSERT: sql = g_strdup_printf ("SELECT %s FROM %s", table->keys_sql, table->name); @@ -801,12 +801,12 @@ audit_action_v (Audit *audit, { /* find the field */ field_name = (gchar *)gda_data_model_get_column_title (dm, col); - insert_value (audit, id, table, field_name, + insert_value (zak_audit, id, table, field_name, gdaex_data_model_get_value_stringify_at (dm, 0, col)); } break; - case AUDIT_ACTION_BEFORE_UPDATE: + case ZAK_AUDIT_ACTION_BEFORE_UPDATE: if (priv->fields_updated != NULL) { g_hash_table_destroy (priv->fields_updated); @@ -849,10 +849,10 @@ audit_action_v (Audit *audit, } break; - case AUDIT_ACTION_AFTER_UPDATE: + case ZAK_AUDIT_ACTION_AFTER_UPDATE: if (priv->fields_updated == NULL) { - g_warning ("You must call before an action of type AUDIT_ACTION_AFTER_UPDATE."); + g_warning ("You must call before an action of type ZAK_AUDIT_ACTION_AFTER_UPDATE."); return FALSE; } @@ -890,15 +890,15 @@ audit_action_v (Audit *audit, value = (gchar *)g_hash_table_lookup (priv->fields_updated, (gconstpointer)field_name); value_new = gdaex_data_model_get_value_stringify_at (dm, 0, col); - if ((get_field_from_name (audit, table, (const gchar *)field_name))->is_key) + if ((get_field_from_name (zak_audit, table, (const gchar *)field_name))->is_key) { /* the key is always saved with old and new values */ - insert_value (audit, id, table, field_name, g_strconcat (value, "|", value_new, NULL)); + insert_value (zak_audit, id, table, field_name, g_strconcat (value, "|", value_new, NULL)); } else if (g_strcmp0 (value, value_new) != 0) { /* field changed: must be saved the old value */ - insert_value (audit, id, table, field_name, value); + insert_value (zak_audit, id, table, field_name, value); } } @@ -906,7 +906,7 @@ audit_action_v (Audit *audit, priv->fields_updated = NULL; break; - case AUDIT_ACTION_DELETE: + case ZAK_AUDIT_ACTION_DELETE: /* saving all fields */ sql = g_strdup_printf ("SELECT %s FROM %s", table->fields_sql, @@ -939,7 +939,7 @@ audit_action_v (Audit *audit, { /* find the field */ field_name = (gchar *)gda_data_model_get_column_title (dm, col); - insert_value (audit, id, table, field_name, + insert_value (zak_audit, id, table, field_name, gdaex_data_model_get_value_stringify_at (dm, 0, col)); } break; @@ -952,8 +952,8 @@ audit_action_v (Audit *audit, } /** - * audit_action_from_gdastatement: - * @audit: an #Audit object. + * zak_audit_action_from_gdastatement: + * @zak_audit: an #ZakAudit object. * @action: the action's type. * @username: the username that make the action. * @datasource_name: the datasource's name. @@ -962,8 +962,8 @@ audit_action_v (Audit *audit, * Returns: #TRUE on success. */ gboolean -audit_action_from_gdastatement (Audit *audit, - enum AuditActions action, +zak_audit_action_from_gdastatement (ZakAudit *zak_audit, + enum ZakAuditActions action, const gchar *username, const gchar *datasource_name, GdaStatement *gda_statement) @@ -1057,29 +1057,29 @@ audit_action_from_gdastatement (Audit *audit, if (g_strcmp0 (str, "") != 0) { - ret = audit_action_v (audit, action, username, datasource_name, table_name, (const gchar **)g_strsplit (str, "|", -1)); + ret = zak_audit_action_v (zak_audit, action, username, datasource_name, table_name, (const gchar **)g_strsplit (str, "|", -1)); } return ret; } /** - * audit_destroy: + * zak_audit_destroy: * */ void -audit_destroy (Audit *audit) +zak_audit_destroy (ZakAudit *zak_audit) { - AuditPrivate *priv = AUDIT_GET_PRIVATE (audit); + ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit); gdaex_free (priv->gdaex); - g_free (audit); + g_free (zak_audit); } /** - * audit_get_record_at: - * @audit: an #Audit object. + * zak_audit_get_record_at: + * @zak_audit: an #ZakAudit object. * @datasource: * @table: * @tm_time: @@ -1087,7 +1087,7 @@ audit_destroy (Audit *audit) * Returns: the record with the specified key at the specified timestamp. */ gboolean -audit_get_record_at (Audit *audit, +zak_audit_get_record_at (ZakAudit *zak_audit, const gchar *datasource_name, const gchar *table_name, struct tm *tm_time, @@ -1098,7 +1098,7 @@ audit_get_record_at (Audit *audit, Datasource *datasource; /* find the datasource */ - datasource = get_datasource_from_name (audit, datasource_name); + datasource = get_datasource_from_name (zak_audit, datasource_name); if (datasource == NULL) { g_warning ("Unable to find the datasource \"%s\" on loaded datasources.", diff --git a/src/libaudit.h b/src/libaudit.h deleted file mode 100644 index 3633949..0000000 --- a/src/libaudit.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * audit.h - * - * Copyright (C) 2005-2010 Andrea Zagli - * - * This file is part of libaudit. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include - -#ifndef __AUDIT_H__ -#define __AUDIT_H__ - -G_BEGIN_DECLS - - -#define TYPE_AUDIT (audit_get_type ()) -#define AUDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUDIT, Audit)) -#define AUDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUDIT, AuditClass)) -#define IS_AUDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUDIT)) -#define IS_AUDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUDIT)) -#define AUDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUDIT, AuditClass)) - -typedef struct _Audit Audit; -typedef struct _AuditClass AuditClass; - -struct _Audit - { - GObject parent; - }; - -struct _AuditClass - { - GObjectClass parent_class; - }; - -GType audit_get_type (void) G_GNUC_CONST; - -enum AuditActions - { - AUDIT_ACTION_INVALID, - AUDIT_ACTION_INSERT, - AUDIT_ACTION_BEFORE_UPDATE, - AUDIT_ACTION_AFTER_UPDATE, - AUDIT_ACTION_DELETE - }; - -Audit *audit_new (GdaConnection *gda_connection); - -Audit *audit_new_from_string (const gchar *cnc_string); - -gboolean audit_action (Audit *audit, - enum AuditActions action, - const gchar *dn, - const gchar *datasource_name, - const gchar *table_name, - ...); - -gboolean audit_action_v (Audit *audit, - enum AuditActions action, - const gchar *dn, - const gchar *datasource_name, - const gchar *table_name, - const gchar **fields_values); - -gboolean audit_action_from_gdastatement (Audit *audit, - enum AuditActions action, - const gchar *dn, - const gchar *datasource_name, - GdaStatement *gda_statement); - -void audit_destroy (Audit *audit); - - -G_END_DECLS - -#endif /* __AUDIT_H__ */ diff --git a/src/libzakaudit.h b/src/libzakaudit.h new file mode 100644 index 0000000..f8b963d --- /dev/null +++ b/src/libzakaudit.h @@ -0,0 +1,94 @@ +/* + * libzakaudit.h + * + * Copyright (C) 2005-2010 Andrea Zagli + * + * This file is part of libzak_audit. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include + +#ifndef __ZAK_AUDIT_H__ +#define __ZAK_AUDIT_H__ + +G_BEGIN_DECLS + + +#define TYPE_ZAK_AUDIT (zak_audit_get_type ()) +#define ZAK_AUDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ZAK_AUDIT, ZakAudit)) +#define ZAK_AUDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ZAK_AUDIT, ZakAuditClass)) +#define IS_ZAK_AUDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ZAK_AUDIT)) +#define IS_ZAK_AUDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ZAK_AUDIT)) +#define ZAK_AUDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ZAK_AUDIT, ZakAuditClass)) + +typedef struct _ZakAudit ZakAudit; +typedef struct _ZakAuditClass ZakAuditClass; + +struct _ZakAudit + { + GObject parent; + }; + +struct _ZakAuditClass + { + GObjectClass parent_class; + }; + +GType zak_audit_get_type (void) G_GNUC_CONST; + +enum ZakAuditActions + { + ZAK_AUDIT_ACTION_INVALID, + ZAK_AUDIT_ACTION_INSERT, + ZAK_AUDIT_ACTION_BEFORE_UPDATE, + ZAK_AUDIT_ACTION_AFTER_UPDATE, + ZAK_AUDIT_ACTION_DELETE + }; + +ZakAudit *zak_audit_new (GdaConnection *gda_connection); + +ZakAudit *zak_audit_new_from_string (const gchar *cnc_string); + +gboolean zak_audit_action (ZakAudit *zak_audit, + enum ZakAuditActions action, + const gchar *dn, + const gchar *datasource_name, + const gchar *table_name, + ...); + +gboolean zak_audit_action_v (ZakAudit *zak_audit, + enum ZakAuditActions action, + const gchar *dn, + const gchar *datasource_name, + const gchar *table_name, + const gchar **fields_values); + +gboolean zak_audit_action_from_gdastatement (ZakAudit *zak_audit, + enum ZakAuditActions action, + const gchar *dn, + const gchar *datasource_name, + GdaStatement *gda_statement); + +void zak_audit_destroy (ZakAudit *zak_audit); + + +G_END_DECLS + +#endif /* __ZAK_AUDIT_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am index ee3ccac..be73437 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,11 @@ -LIBS = $(LIBAUDIT_LIBS) \ +LIBS = $(LIBZAKAUDIT_LIBS) \ -export-dynamic -AM_CPPFLAGS = $(LIBAUDIT_CFLAGS) \ +AM_CPPFLAGS = $(LIBZAKAUDIT_CFLAGS) \ -I$(top_srcdir)/src noinst_PROGRAMS = test1 -LDADD = $(top_builddir)/src/libaudit.la +LDADD = $(top_builddir)/src/libzakaudit.la EXTRA_DIST = test1.sql diff --git a/tests/test1.c b/tests/test1.c index 50cbdce..58da167 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -22,13 +22,13 @@ #include -#include +#include int main (int argc, char *argv[]) { GdaEx *gdaex; - Audit *audit; + ZakAudit *audit; GdaConnection *conn; GdaSqlParser *parser; @@ -36,7 +36,7 @@ main (int argc, char *argv[]) g_type_init (); - audit = audit_new_from_string ("PostgreSQL://postgres:postgres@HOST=localhost;DB_NAME=audit"); + audit = zak_audit_new_from_string ("PostgreSQL://postgres:postgres@HOST=localhost;DB_NAME=audit"); if (audit == NULL) { @@ -58,11 +58,11 @@ main (int argc, char *argv[]) gdaex_execute (gdaex, "DELETE FROM test1"); gdaex_execute (gdaex, "INSERT INTO test1 VALUES (1, 'Mary Red', 25, 1500.45)"); - audit_action (audit, AUDIT_ACTION_INSERT, "I", "audit_test1", "test1", "id", "1", NULL); + zak_audit_action (audit, ZAK_AUDIT_ACTION_INSERT, "I", "audit_test1", "test1", "id", "1", NULL); - audit_action (audit, AUDIT_ACTION_BEFORE_UPDATE, "I", "audit_test1", "test1", "id", "1", NULL); + zak_audit_action (audit, ZAK_AUDIT_ACTION_BEFORE_UPDATE, "I", "audit_test1", "test1", "id", "1", NULL); gdaex_execute (gdaex, "UPDATE test1 SET age=30 WHERE id = 1"); - audit_action (audit, AUDIT_ACTION_AFTER_UPDATE, "I", "audit_test1", "test1", "id", "1", NULL); + zak_audit_action (audit, ZAK_AUDIT_ACTION_AFTER_UPDATE, "I", "audit_test1", "test1", "id", "1", NULL); stmt = gda_sql_parser_parse_string (parser, "INSERT INTO test1 (id, name, age, income) VALUES (2, 'Paul Green', 105, 35.33)", NULL, NULL); if (stmt == NULL) @@ -71,7 +71,7 @@ main (int argc, char *argv[]) return 0; } gda_connection_statement_execute_non_select (conn, stmt, NULL, NULL, NULL); - audit_action_from_gdastatement (audit, AUDIT_ACTION_INSERT, "I", "audit_test1", stmt); + zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_INSERT, "I", "audit_test1", stmt); stmt = gda_sql_parser_parse_string (parser, "UPDATE test1 SET income=99999999.99 WHERE id = 2", NULL, NULL); if (stmt == NULL) @@ -79,9 +79,9 @@ main (int argc, char *argv[]) g_warning ("GdaStatement NULL"); return 0; } - audit_action_from_gdastatement (audit, AUDIT_ACTION_BEFORE_UPDATE, "I", "audit_test1", stmt); + zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_BEFORE_UPDATE, "I", "audit_test1", stmt); gda_connection_statement_execute_non_select (conn, stmt, NULL, NULL, NULL); - audit_action_from_gdastatement (audit, AUDIT_ACTION_AFTER_UPDATE, "I", "audit_test1", stmt); + zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_AFTER_UPDATE, "I", "audit_test1", stmt); stmt = gda_sql_parser_parse_string (parser, "DELETE FROM test1 WHERE id = 2", NULL, NULL); @@ -90,10 +90,10 @@ main (int argc, char *argv[]) g_warning ("GdaStatement NULL"); return 0; } - audit_action_from_gdastatement (audit, AUDIT_ACTION_DELETE, "I", "audit_test1", stmt); + zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_DELETE, "I", "audit_test1", stmt); gda_connection_statement_execute_non_select (conn, stmt, NULL, NULL, NULL); - audit_destroy (audit); + zak_audit_destroy (audit); return 0; }